Word

Insert/Remove Watermark

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

lucas

Description:

Inserts and removes a watermark with text of your choice. 

Discussion:

Your documents need to be circulated for approval, etc. before final release. You need everyone to know it's a draft. When all approval criteria is met and its ready for publication, you need to be able to remove the watermark. 

Code:

instructions for use

			

Place this code In a standard module: Option Explicit Sub InsertWaterMark() Dim strWMName As String On Error GoTo ErrHandler 'selects all the sheets ActiveDocument.Sections(1).Range.Select strWMName = ActiveDocument.Sections(1).Index ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 'Change the text for your watermark here Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1, _ "DRAFT", "Arial", 1, False, False, 0, 0).Select With Selection.ShapeRange .Name = strWMName .TextEffect.NormalizedHeight = False .Line.Visible = False With .Fill .Visible = True .Solid .ForeColor.RGB = Gray .Transparency = 0.5 End With .Rotation = 315 .LockAspectRatio = True .Height = InchesToPoints(2.42) .Width = InchesToPoints(6.04) With .WrapFormat .AllowOverlap = True .Side = wdWrapNone .Type = 3 End With .RelativeHorizontalPosition = wdRelativeVerticalPositionMargin .RelativeVerticalPosition = wdRelativeVerticalPositionMargin 'If using Word 2000 you may need to comment the 2 'lines above and uncomment the 2 below. ' .RelativeHorizontalPosition = wdRelativeVerticalPositionPage ' .RelativeVerticalPosition = wdRelativeVerticalPositionPage .Left = wdShapeCenter .Top = wdShapeCenter End With ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Exit Sub ErrHandler: MsgBox "An error occured trying to insert the watermark." & Chr(13) & _ "Error Number: " & Err.Number & Chr(13) & _ "Decription: " & Err.Description, vbOKOnly + vbCritical, "Error" End Sub Sub RemoveWaterMark() Dim strWMName As String On Error GoTo ErrHandler ActiveDocument.Sections(1).Range.Select strWMName = ActiveDocument.Sections(1).Index ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader Selection.HeaderFooter.Shapes(strWMName).Select Selection.Delete ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Exit Sub ErrHandler: MsgBox "An error occured trying to remove the watermark." & Chr(13) & _ "Error Number: " & Err.Number & Chr(13) & _ "Decription: " & Err.Description, vbOKOnly + vbCritical, "Error" End Sub

How to use:

  1. Open the Visual Basic Editor by going to tools-Macro's-Visual Basic Editor or use Alt-F11
  2. On the toolbar of the Visual Basic Editor, go to insert - module
  3. In the module pane paste the code above.
  4. Close the Visual Basic Editor by clicking the X in the upper right corner or go to File-Close
 

Test the code:

  1. Go to Tools-Macro, Click on Macro and when the form pops up click on the macro: InsertWaterMark
  2. To remove the watermark, repeat the procedure except choose the RemoveWaterMark macro
 

Sample File:

add-remove_watermark.zip 8.18KB 

Approved by mdmackillop


This entry has been viewed 139 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express