WD97: Macro to Turn All Field Codes On and OffLast reviewed: February 11, 1998Article ID: Q159968 |
The information in this article applies to:
SUMMARYThis article discusses two methods for turning fields codes on or off. The first method adds a built-in button to the Standard toolbar. The second method uses Microsoft Visual Basic for Applications to create a macro that turns all field codes in a document on or off.
MORE INFORMATION
Method 1: Add the built-in View Field Codes button to the Standard toolbar
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Word 97 Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q120802 TITLE: Office: How to Add/Remove a Single Office Program or Component Method 2: Use the ShowFieldCodes propertyThe following Visual Basic macro uses the ShowFieldCodes property and displays a message in the status bar to indicate whether field codes are on or off. Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used inall situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.
Sub ToggleAllFieldCodes() If ActiveWindow.View.ShowFieldCodes Then ActiveWindow.View.ShowFieldCodes = False StatusBar = "Field Codes Off" Else ActiveWindow.View.ShowFieldCodes = True StatusBar = "Fields Codes On" End If End Sub Method 3: Use the following simpler approachesThe following two macro examples are a simpler approach, however there is no notification of the current field code state provided in the previous example. Example 1:
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodesExample 2:
ActiveWindow.Document.Fields.ToggleShowCodesFor information about how to do this in earlier versions of Word, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q99954 TITLE : Macro to Toggle All Document Field Codes On and Off |
Additional query words: word8 word97 8.0 8.0 vb vba vbe
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |