Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Identifying Character in a Text String

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Montana DOJ Help Desk - 14 Jan 2005 05:12 GMT
Word 2000

I have a string of text that contains an unknown character.  I need to
identify the character code.  I've done this before, so I know that it's
possible, but I'm drawing a complete blank on the command that I used, and I
haven't been able to find the information in Help.

Can someone show me how to get the character code of an unknown character?

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
Jean-Guy Marcil - 14 Jan 2005 06:11 GMT
Montana DOJ Help Desk was telling us:
Montana DOJ Help Desk nous racontait que :

> Word 2000
>
[quoted text clipped - 5 lines]
> Can someone show me how to get the character code of an unknown
> character?

Select one character on the page and try:
   MyCharCode = Asc(Selection.Text)

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Klaus Linke - 14 Jan 2005 16:29 GMT
> Select one character on the page and try:
>     MyCharCode = Asc(Selection.Text)

Better use AscW.
Asc only works for the 200 or so most widely used characters, and returns the codes from the old Windows code page 1252, which
differs in some cases from the "real" (Unicode) codes.

Regards,
Klaus
Jean-Guy Marcil - 14 Jan 2005 16:41 GMT
Klaus Linke was telling us:
Klaus Linke nous racontait que :

>> Select one character on the page and try:
>>     MyCharCode = Asc(Selection.Text)

Good to know!

Will AscW return the real Unicode number for the Wingding et all. sets (or
other inserted "symbols")?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Klaus Linke - 14 Jan 2005 19:43 GMT
> Will AscW return the real Unicode number for the Wingding et all.
> sets (or other inserted "symbols")?

With regular fonts, you don't have much problems.
Each symbol has it's specific code, independent of the font.

Say 263A, Alt+X (or using the decimal code: Alt+9786) produces the Unicode character "white smiling face", or smiley (though most fonts may not contain that special symbol).
AscW(Selection.Text) used on that character will give you 9786,
Hex(AscW(Selection.Text)) will give you 263A.

But decorative fonts like the Wingdings font you have mentioned are problematic.
Word has no way to determine what symbols such a symbol font may contain.
Those symbols aren't even necessarily defined in the Unicode Standard.

So Word uses codes in the code page at U+F000 (decimal 61440) for them.

Take a "smiley" from Wingdings as an example,
-- It is produced by the "J" key
(which has hex code 4A, or decimal code 74)
-- corresponds to U+F04A (= F000+4A)
equals decimal 61514 (61440+74)

You can for example search for it with u+61514 in "Find what".
Or you can insert it in text using ChrW(61514) or ChrW(&HF04A) in a macro (or F04A, Alt+X, or Alt+61514, in text), and format it in "Wingdings" font.
Here you need both the code and the font to specify the character.

Regards,
Klaus
Jean-Guy Marcil - 14 Jan 2005 20:57 GMT
Klaus Linke was telling us:
Klaus Linke nous racontait que :

>> Will AscW return the real Unicode number for the Wingding et all.
>> sets (or other inserted "symbols")?
[quoted text clipped - 28 lines]
> "Wingdings" font.
> Here you need both the code and the font to specify the character.

Ouch!
Messy!

Thanks for taking the time!

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Klaus Linke - 14 Jan 2005 22:29 GMT
> Ouch!
> Messy!

Well, not at all if you can avoid decorative (symbol) fonts...

> Thanks for taking the time!

Pas de quoi!
Klaus
Montana DOJ Help Desk - 18 Jan 2005 05:32 GMT
Thanks for the help!  That's exactly what I needed.  I was thinking that the
last time I did this, I used a variation of the Chr function, so I was
looking right past the Asc function, even though it is listed in the See
Also list under several topics that I had previously looked at in Help.  I
just had this pre-conceived notion of where I was suppose to be looking, and
I just could not break out of that mindset.

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
> Montana DOJ Help Desk was telling us:
> Montana DOJ Help Desk nous racontait que :
[quoted text clipped - 11 lines]
> Select one character on the page and try:
>     MyCharCode = Asc(Selection.Text)

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.