Microsoft KB Archive/74894

{|
 * width="100%"|

WD: WordBasic Macros to Find the ANSI Value of Characters

 * }

Q74894

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows 95, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

-

SUMMARY
To troubleshoot a problem or search for an extended character, you may need to find the ANSI value of a string of text in Microsoft Word.

MORE INFORMATION
Below are two simple macros to find the ANSI value of a string of text. The first is for one character selections and the second is for strings or formatting characters.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Macro 1
  Sub Main A$=Selection$ '* A$ = highlighted text Print Asc(A$)  '* Print ANSI value of the first '* character in A$ on the Status bar. End Sub This macro displays its result on the status bar.

Macro 2
You can use this macro for formatting characters or dissecting any size text string. It displays both character and ANSI values in a message box.

  Sub Main A$ = Selection$              '*A$=Highlighted text While Len(A$) >=1              '* While the Length of A$ is                                      '* greater than 1 CharValue = ASC(A$)            '* the ANSI value of 1st character If Len(A$) >1 Then             '* Reducing the length of A$              A$ = Mid$(A$, 2)        '* A$ = A$ minus the 1st character Else A$=&quot;&quot;                  '* A$ = nothing End if     MsgBox Chr$(34) + Chr$(CharValue) + Chr$(34) + &quot; ASC val = &quot; + Str$(CharValue)                '* Display values in a message box Wend                           '* end while loop End Sub To use these macros most efficiently, follow these steps:


 * 1) From the Tools menu in Word for Windows 2.0, choose Macro, type a macro name, and choose the Edit button. From the Macro menu in Word for Windows 1.x, choose Edit, type a macro name, and choose the OK button.
 * 2) Type the macro.
 * 3) Choose File, Close, and save the macro when prompted.
 * 4) Select the text to run the macro on.
 * 5) Choose Tools, Macro. Highlight the macro name and choose Run.

Additional query words: tshoot

Keywords : kbtshoot wordnt kbmacroexample kbfield winword macword word6 winword2 word7 word95 kbhowto

Issue type :

Technology : kbHWMAC kbOSMAC kbWordSearch kbWordMacSearch kbWord700Search kbZNotKeyword2 kbWord600Mac kbWord601aMac kbWord601Mac kbWord600 kbWord600a kbWord600c kbWord200 kbWord200a kbWord200b kbWord200c kbWord100 kbWord110 kbWord700 kbWord110a kbWord700a