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
Wow and thanks Vishal; very much appreciated! I’m new to VBA in Word and Excel, and this was perfect in Word! Haven’t done macros in over 2 decades and needed to jump back on it.
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.
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?
Great job. How do you research this stuff?
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!
This if for a MS Word document. I have WordPerfect.
hi Vishal
how to do this in word 2007.
Good work Vishal. You have created watermark in Microsoft word that benefit many people. Well done!!
__________________________________________________________________________
Micheal Smith
Good work Vishal. you have done a great job and your invention become useful to people who use Microsoft word.
_________________________________________________________________________
Alex
Good work Vishal. you have done a great job and your invention become useful to people who use Microsoft word
Thanks
Worked like a charm…
dm