Insert Unicode Characters Into Code

D

Diamonds_Mine

In my macro, I need to insert the following text: "Liczba stron Å‚Ä…cznie z
tytułową". However, I need assistance with inserting the special characters
that are being used. When I copy/paste the text from a Word document, some
of the characters become question marks. This is the code:

Selection.TypeText "Liczba stron ??cznie z tytu?ow?:"
ActiveDocument.Bookmarks("lblFipo").Select

Thank you for any assistance you can provide.
 
D

Dave Lett

Hi,

You will need to know the unicode character number for each of the special
characters that you're trying to insert. You can select each special
character and use the following to get the unicode character:

MsgBox AscW (Selection.Text)

which returns 322 for the l character

Therefore, if I want to insert the first word in your example, I would use
something like the following:

Selection.InsertSymbol CharacterNumber:=322, Unicode:=True
Selection.InsertSymbol CharacterNumber:=261, Unicode:=True
Selection.TypeText "cznie"

HTH,
Dave
 
K

Klaus Linke

Diamonds_Mine said:
In my macro, I need to insert the following text: "Liczba stron lacznie z
tytulowa". However, I need assistance with inserting the special
characters
that are being used. When I copy/paste the text from a Word document,
some
of the characters become question marks. This is the code:

Selection.TypeText "Liczba stron ??cznie z tytu?ow?:"
ActiveDocument.Bookmarks("lblFipo").Select

Thank you for any assistance you can provide.


You could also crank up the macro recorder, paste the text in "Edit > Find",
and do a search.
That should give you a string to work with, something like
"Liczba stron " & ChrW(322) & ChrW(261) & "cznie z tytu" & _
ChrW(322) & "ow" & ChrW(261)

Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top