2 Replies Latest reply on May 23, 2012 10:02 AM by Brian Dalton

    Request: Macro for auto-updating Watermark in Word

    Brian Dalton

      I wanted to create a watermark in our Word documents that updates from an EPDM card variable.  I dug around and found some code online that seemed to do the job - it was much more complicated than I had expected.

       

      Now, after using it for 3 weeks it suddenly doesn't work anymore, and consistently gives a 'Library not found' error.  I don't have the time to learn how the code works and try to figure out how to fix it so I've just disabled the function at this time.

       

      I would, however like to be able to use this concept and I'm wondering if anyone has a functioning macro for updating a Word watermark from a card variable that they would be willing to share?

        • Re: Request: Macro for auto-updating Watermark in Word
          Gurumoorthy Govindan

          Hi Brian,

           

          Please find the macro content found in the admin guide to auto update word files,

           

          Adding a Refresh Macro

          Instead of manually updating the fields that are linked to a custom variable, you can

          create a macro that automatically updates the fields every time a document is opened.

          Without the macro, if you update the value of the linked fields by editing the file data

          card, the values are not automatically updated when you open the document. To update

          the fields, you must select them and refresh them by pressing F9.

          To add a refresh macro:

          1. 1. Start Microsoft Word.
          2. 2. Select Tools > Macro > Macro, or press Alt + F8.
          3. 3. For Macro name field, type AutoOpen and click Create .
          4. 4. In the code window, insert the following macro code between Sub AutoOpen() and

          End Sub:

          Dim aStory As Range

          Dim aField As Field

          For Each aStory In ActiveDocument.StoryRanges

          For Each aField In aStory.Fields

          1. aField.Update

          Next aField

          Next aStory

          1. 5. Save and close the code window.

          The next time you open a document with fields that are linked to Enterprise PDM variables,

          the fields will be automatically updated.

          346

          Variables

          when the fields are updated, the document is modified and Word asks if the new

          changes should be saved when closing the document.

           

           

           

           

           

          Kind Regards,

          Guru.