Microsoft KB Archive/99956

-

{| The information in this article applies to:
 * width="100%"|
 * 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 &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.

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

&quot;Using WordBasic&quot; by WexTech Systems, Inc., and Microsoft Corporation, Microsoft Press, 1992
 * }

-

Last reviewed: July 30, 1997

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.