Macro to Run Macro or Insert Glossary, as in Word for MS-DOS

Last reviewed: July 30, 1997
Article ID: Q99956
The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c

SUMMARY

In Microsoft Word for MS-DOS, the F3 key is used to run a macro or insert a glossary entry whose name matches the word to the left of the insertion point. The following macro in Word for Windows can be assigned to the F3 key to achieve the same behavior.

WARNING: 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.

Sub MAIN
WordLeft 1, 1                'Select word to left of insertion point
name$ = Selection$()                      'Assign word to a variable
If GetGlossary$(name$, 0) <> "" Then        'Test for glossary entry
 EditClear
 EditGlossary .Name = name$           'If true, insert glossary entry
Else
 On Error Goto errors
 exe = IsExecuteOnly("Global:" + name$)
 EditClear
 ToolsMacro .Name = name$, .Run         'Run global macro if it exists
End If errors: If err = 511 Then Print "No macro or glossary exists by the name"
End Sub

The above macro selects the word to the left of the insertion point and assigns the text to the name$ string. If a global glossary entry exists with the same name, the contents are inserted into the document window. If a glossary entry does not exist with the specified name, then the macro checks whether the name refers to a macro. If a macro with the specified name is found, the ToolsMacro statement runs the macro.

Reference(s):

"Using WordBasic" by WexTech Systems, Inc., and Microsoft Corporation, Microsoft Press, 1992


KBCategory: kbmacro
KBSubcategory:
Additional query words: 2.0 2.0a 2.0a-cd 2.0b 2.0c winword2
winword F3 insert editglossary toolsmacro


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.