Determining special characters/formatting in documents

D

Dan

I am opening an RTF file in Word. Here is a snippet of the RTF file:

all:\lang1032 \lang1033\i D\lang1032\f1\'ef\lang1033\f0 I rejoice

This is displayed in Word as:

all: Do I rejoice

If I search for the letter "o", it will find the one in "rejoice" but not
the one in "Do". If I copy and paste the "o" in "Do" to the Find window, it
will find it and a few other instances of that character in the document. It
obviously has some different formatting and/or character definition than the
"o" straight from the keyboard. How can I find out in Word what this
character/formatting is? In WordPerfect I had something called "Reveal Codes"
where I could look at the underlying structure of the document. I am trying
to do the same type of thing in VB and VB.NET, but I cannot figure out how to
programatically find these special characters. Can someone please help me?
Thanks!
 
P

Pesach Shelnitz

You can find the coding of any character that appears in a Word document by
blocking the character and then pressing Insert Symbol. When the Symbol
dialog box opens, the character in your document should be selected, and
further information about your character, including its hexadecimal Unicode
character code should be displayed. To find the character in VBA, you first
need to convert the hexadecimal character code to a decimal number. For
example, if the hexadecimal number is 00EF, the decimal code would be 239.
Then insert the decimal code as the parameter passed to ChrW as in the
following example.

With Selection.Find
.ClearFormatting
.Execute findText:=ChrW(239), Wrap:=wdFindStop, Forward:=True
End With

Hope this helps,
Pesach Shelnitz
 
D

Dan

Thank you for your reply. It was very helpful. I was not aware of the ChrW
(and AscW) functions, and the suggestion to check the Insert Symbol dialog
box was also a good one to help me solve my problem.

Dan
 

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