Macro Example: Find Field and Change to Text in Header/Footer

Last reviewed: February 5, 1998
Article ID: Q136068
The information in this article applies to:
  • Microsoft Word for Windows 95, version 7.0

SUMMARY

The macro example below demonstrates how to search for a particular field and unlink the field result to normal text.

MORE INFORMATION

This macro example opens a new document, opens the footer, and inserts the field Filename. It then finds the Filename field and unlinks the field result to normal text.

WARNING: ANY USE BY YOU OF THE OR MACRO 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
     ScreenUpdating 0
     FileNewDefault
     ViewFooter
     InsertField .Field = "filename"
     StartOfWindow
     EndOfWindow 1
     ToggleFieldDisplay
     EditFind .Find = "^d filename", .Wrap = 0
     If EditFindFound() Then UnlinkFields
     ToggleFieldDisplay
     CloseViewHeaderFooter
     ScreenUpdating 1
End Sub


KBCategory: kbusage kbmacro
KBSubcategory: kbfield kbmacroexample
Additional reference words: 7.0 word95 winword word7
Keywords : kbfield kbmacroexample
Version : 7.0
Platform : WINDOWS


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: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.