CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
Cesky English Deutsch
 Visitors: 1755 

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    2167×  
Prices - CAD eShop:
applies to: AutoCAD · AutoCAD LT ·

See also:
Tip 11788:Invalid number or bad continuation - when creating a linetype.
Tip 11735:How to enter the symbol № (numero) in AutoCAD?
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

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   

Link your AutoCAD texts with Excel tables/sheets. Export. Change. Import.
Try DwgText 2015 More info

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.