none
Macro for changing or deleting field codes RRS feed

  • Question

  • I need a VBA macro for Word to search and replace each mergefield with either:
    1. a new mergefield, or
    2. a different field code , or
    3. text without any field code.

    For example, I want to do three things to each document:
    - Find all instances of { MERGEFIELD  Street_Name } and replace with { MERGEFIELD Addr1}
    - Find all instances of { MERGEFIELD  Commission1 } and replace with {FORMCHECKBOX}. 
    - Find all instances of { MERGEFIELD  Start_date } and replace with "Date:______".  

    I need to apply this to thousands of documents. 

    I'm using Word 2011 (Mac version).

    I have a macro for the first case which searches for the text in the mergefield, but I don't know how to deal with the other two cases. I'm new to VBA.

    Thanks!
    Monday, March 20, 2017 9:53 PM

All replies

  • I don't speak 'Mac' but have you considered that formfields and mail merge are mutually exclusive in Word?

    The 'thousands' of documents sets up more alarm bells as documents that have been merged do not contain merge fields, so before anyone - even those who speak 'Mac' - can answer your question and not dig you a deeper hole, it would be beneficial to know what EXACTLY you are trying to achieve here.


    Graham Mayor - Word MVP
    www.gmayor.com

    Wednesday, March 22, 2017 6:17 AM