CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 1947

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
  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:

100% *  CAD 
28.8.2017    6441×  
Prices - CAD eShop:
applies to: AutoCAD · AutoCAD LT ·

See also:
Tip 13139:How to insert a new line into multiline text in the Find/Replace command?
Tip 12863:Do you know the difference among the fonts ISOCP, ISOCP2 a ISOCP3?
Tip 12782:How to insert a character in Kanji or Pinyin into Fusion 360?
Tip 12562:How to display cyrillic or special math symbols in a DCL dialog?
Tip 12181:Using a YES/NO parameter in Revit schedules.

Back   All CAD Tips

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   

Extend your AutoCAD LT productivity with our popular add-on
CADstudio LT Extension More info

Please use these tips at your own risk.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.