CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 3272 

CAD tip CAD tip # 11580:

Question CAD 
 %  platform  category 
Q - question

Excel: convert Unicode texts to \U+ codes for AutoCAD

A - answer With the following VBA macro you can use Excel to convert any Unicode text (cyrillic - russian, arabic, chinese, japanese, korean, greek and other two-byte characters) to encoded text for AutoCAD. Such encoded text can be then pasted into an AutoCAD text object. If such text object uses a text style based on an appropriate font (containing foreign-language characters), the text will be properly displayed in any AutoCAD version.

The custom function ACADunicode:

The code of the VBA function (Alt+F11 in Excel, Insert>Module):

Function ACADunicode(s)
cvt = ""
For i = 1 To Len(s)
 c = Mid(s, i, 1)
 x = StrConv(c, vbUnicode)
 If Mid(x, 2, 1) = Chr(0) Then
  cvt = cvt & c
 Else
  cvt = cvt & "\U+" & _
  Right("0" & Hex(Asc(Mid(x, 2, 1))), 2) & _
  Right("0" & Hex(Asc(Mid(x, 1, 1))), 2)
 End If
Next i
ACADunicode = cvt
End Function

You can invoke in Excel in a standard way, similarly as other embedded functions - e.g. =ACADunicode(A1) - converts the text from the cell A1.

The resulting text in AutoCAD:

ACADLT
100% *  CAD 
28.8.2017    495×  
Comments   Tell a friend
applies to: AutoCAD · AutoCAD LT ·

See also:
Tip 10668:How to enter a square root sign in AutoCAD text?
Tip 9619:How to get rid of "----" in empty fields?
Tip 8657:Import error: No point file format match found
Tip 8521:How to type greater or equal, less or equal in AutoCAD (≤ ≥)?
Tip 7520:DWG to PDF problem in an arabic font.


Back   All CAD Tips All CAD tips&tricks

How to compare changes between two versions of a Revit BIM project? « | » What is the Linked account in your Autodesk Account profile?

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   



Featuring:
DwgTextTranslator translates a series of drawings from one language to another using MS Access.
Download a fully functional trial version.


Please use these tips at your own risk.
CAD Studio (Xanadu) is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist