WD: How to Use the MACROBUTTON Field in WinWord Documents

ID: Q78835

The information in this article applies to:

SUMMARY

With the MACROBUTTON field in Microsoft Word for Windows, you can create a button in your document that invokes a macro when you double- click it. The syntax of this field is as follows

   {MACROBUTTON macroName buttonText}

where macroName is the name of the macro you want the button to invoke, and buttonText is the text or graphic you want to serve as the button in the document. To insert the field braces, press CTRL+F9.

When you display the result of the MACROBUTTON field, either the text or graphic that you specified as the buttonText instruction is displayed. Word automatically updates the field's result whenever you edit the field. If you have a mouse, double-click the text or graphic returned by the MACROBUTTON field to run the macro specified in the field's macroName argument. If you don't have a mouse, use the keyboard to select the text or graphic returned by the MACROBUTTON field, and press ALT+SHIFT+F9 to run the specified macro.

MORE INFORMATION

There are two ways to use a graphic (instead of text) to represent the button. The first is to use a separate graphic file, and the second is to include the graphic directly in the document.

Method 1

To use a separate graphic file, in Word version 6.0, the syntax is as follows:

{MACROBUTTON macroName {includepicture c:\\directory\\subdirectory\\file}}

The IMPORT or INCLUDEPICTURE field code is a field code you insert within the MACROBUTTON field telling the program to insert the referenced graphic file. The advantage of this method is that the graphic does not increase the size of your document.

To use a separate graphic file, the field code syntax is as follows for Word versions 1.0 and 2.0:

 {MACROBUTTON macroName {import c:\\directory\\subdirectory\\file}}

Method 2

You can also insert the button graphic directly into your document:

1. Copy the graphic you intend to use as the button to the Clipboard.

   (You  could do this by temporarily placing the graphic somewhere in
   your  document and Cutting it to the Clipboard.)

2. Create a MACROBUTTON field.

3. Place the insertion point in the MACROBUTTON field where the

   buttonText instruction should appear.

4. On the Edit menu, choose Paste Special and select Picture to insert
   the graphic as the button.

The advantage of this method is that if you want to distribute the document to others, you can distribute the document as one file.

REFERENCES

"Word for Windows Companion, Second Edition," pages 555-58

"Word 6 for Windows Companion," pages 707-710

Additional query words: 1.x 2.x 7.0 word95 word6 word7 6.0 6.0a 6.0c winword2 word97 winword

Keywords          : kbfield 
Version           : 1.x 2.x 7.x 97
Platform          : WINDOWS

Last Reviewed: February 6, 1998