bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Macros > WordBasic Examples > Extracting Symbol Characters

Extracting Symbol Characters

Summary: Use this WordBasic macro to pull special characters from a document. (This tip works with Microsoft Word 6, and Word 95.)

Some WordTips readers have extended their use of Word by using macros to automatically add special codes to their documents. For instance, to covert regular text to SGML format. (SGML is a predecessor to HTML and is used for many on-line and publishing needs.) Parsing regular text using macros is no problem, but if you insert a symbol in your document (using the Symbol option from the Insert menu) then parsing can be a bit more complex. This is because Word internally represents the symbol using multiple characters. Thus, the regular ASC function will not work to retrieve a symbol.

Word 6 and Word 95 include a special macro which you can install to allow you to extract the symbol character information. The macro, FindSymbol, is included in the Macros60.dot or Macros70.dot files which can be optionally installed on your system. Simply rerun the Word Setup program and choose to install these macros.

If you are the type that likes to write your own macros, you can parse the symbols by first searching for each occurrence of a left parentheses (ASCII value 40) in your document. Then, you can use GetCurValues and the InsertSymbol object to get the details on the character. As you might imagine, search for a left parentheses also returns many "false" hits, namely those where you simply use the left parentheses in your document. The following WordBasic macro provides an example of how you can get information about the symbols in your document while still bypassing traditional use of the left parentheses.

Sub MAIN
EditFind .Find = "(", .Direction = 0, .MatchCase = 0, .WholeWord = 0, \
 .PatternMatch = 0, .SoundsLike = 0, .Format = 0, .Wrap = 0
   While EditFindFound()
      Dim InsSym As InsertSymbol
      GetCurValues InsSym
      vFont$ = InsSym.Font
      vCharNum$ = InsSym.CharNum
      If vCharNum$ <> "40" Then
         MsgBox "Font: " + vFont$ + Chr$(10) + "CharNum: " + vCharNum$
      EndIf
      RepeatFind
   Wend
End Sub

When you run this macro on an open document, it stops every time it locates a symbol and displays both the font and ASCII value of the symbol. When you click on the OK button, the macro continues looking through the document for the next symbol.

Tip #123 applies to Microsoft Word versions: 6 | 95


More Power! For some people, the prospect of creating Word macros can be scary. WordTips: The Macros can help you conquer your fears and you'll discover you're much more confident and productive as you make Word do exactly what you want. This is an invaluable source for learning macros. You are introduced to the topic in bite-sized chunks, pulled from past issues of WordTips. Learn at your own pace, exactly the way you want.
 
Check out WordTips: The Macros today!

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)