WD: WordBasic Macros to Find the ANSI Value of CharactersLast reviewed: February 24, 1998Article ID: Q74894 |
The information in this article applies to:
SUMMARYTo 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 INFORMATIONBelow 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. The application note titled "WordBasic Macro Examples for Word for Windows 2.0" includes a macro named ANSIChar. For additional information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q100491 TITLE : WD0523: Frequently Requested Macros DescriptionsWARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" 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 SubThis macro displays its result on the status bar.
Macro 2You 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$="" '* A$ = nothing End if MsgBox Chr$(34) + Chr$(CharValue) + Chr$(34) + " ASC val = " + Str$(CharValue) '* Display values in a message box Wend '* end while loop End SubTo use these macros most efficiently, follow these steps:
|
Additional query words: tshoot
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |