Home > MS Word, Tricks n Techniques > MS Word: Remove watermark from all Word pages using VBA

MS Word: Remove watermark from all Word pages using VBA

March 28th, 2008 Leave a comment Go to comments

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
  1. dmang
    January 22nd, 2009 at 10:54 | #1

    Thanks
    Worked like a charm…
    dm

  2. alex
    April 3rd, 2009 at 21:59 | #2

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

  3. alex
    April 3rd, 2009 at 22:00 | #3

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

  4. Micheal Smith
    April 5th, 2009 at 20:25 | #4

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

  5. Madhan
    October 23rd, 2009 at 21:58 | #5

    hi Vishal
    how to do this in word 2007.

  6. Jane Hester
    April 13th, 2010 at 15:45 | #6

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

  1. No trackbacks yet.