MS Word: Remove watermark from all Word pages using VBA

By | March 28, 2008 | 11 Comments
Category: MS Word Tags: , ,

You can create watermark in MS Word document by going to Format Menu > Background > Printed Watermarks… Here you will be able to set Text Watermark in each page. Now if you want to remove the watermark from all pages, use the following VBA script.

   Dim section As Word.section
   Dim pheadertype As Long
   Dim hdr As Range
   Dim sp As Shape
   Dim str As String
   For Each section In ActiveDocument.Sections
      With section
         Set hdr = .Headers(wdHeaderFooterFirstPage).Range
         For Each sp In hdr.ShapeRange
            str = sp.Name
            If InStr(str, "PowerPlusWaterMarkObject") > 0 Then
               sp.Visible = msoFalse
             End If
          Next
          Set hdr = .Headers(wdHeaderFooterPrimary).Range
          For Each sp In hdr.ShapeRange
             str = sp.Name
             If InStr(str, "PowerPlusWaterMarkObject") > 0 Then
                 sp.Visible = msoFalse
             End If
           Next
       End With
    Next

About Vishal Monpara

Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1's and 0's from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.

11 thoughts on “MS Word: Remove watermark from all Word pages using VBA

  1. Jessica

    The code as written doesn’t handle sections with different odd and even headers. You’d have to add this to the main loop:
    Set hdr = .Headers(wdHeaderFooterOdd).Range.
    For Each sp In hdr.ShapeRange
    str = sp.Name
    If InStr(str, “PowerPlusWaterMarkObject”) > 0 Then
    sp.Visible = msoFalse
    End if
    Next

    and something similar using .Headers(wdHeaderFooterEven).Range.


  2. Hugo

    The code specified works fine i.e. no errors BUT why, when I have a 3 page single section document, does the document end up with the watermark removed from page 1 and 3 but not from page2?



  3. Laura

    Thank you this is very helpful. I used the “PowerPlusWaterMarkObject” string to help me get a handle on watermarks in the section and then changed the text to what I wanted!


  4. Jane Hester

    This if for a MS Word document. I have WordPerfect.



  5. Micheal Smith

    Good work Vishal. You have created watermark in Microsoft word that benefit many people. Well done!!
    __________________________________________________________________________
    Micheal Smith


  6. alex

    Good work Vishal. you have done a great job and your invention become useful to people who use Microsoft word.
    _________________________________________________________________________
    Alex


  7. alex

    Good work Vishal. you have done a great job and your invention become useful to people who use Microsoft word



Leave a Reply

Your email address will not be published. Required fields are marked *