Add/Insert Watermark in Word VBA

Add/Insert Watermark in Word VBA

Watermark

Represents background text that is helpful to mark any document as confidential or copyright etc. In this blog we will generate a watermark using VBA which will result like below:

Code example

Sub AddWatermark()
Dim currentDocument As Document
Set currentDocument = ActiveDocument
    currentDocument.Sections(1).Range.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.HeaderFooter.Shapes.AddTextEffect(PowerPlusWaterMarkObject, "TEST WATER MARK", "Arial", 1, False, False, 0, 0).Select
    With Selection.ShapeRange
        .TextEffect.NormalizedHeight = False
        .Line.Visible = False
        .Fill.Visible = True
        .Fill.Solid
        .Fill.ForeColor.RGB = RGB(192, 192, 192)
        .Fill.Transparency = 0.5
        .Rotation = 315
        .LockAspectRatio = True
        .Height = CentimetersToPoints(6.41)
        .Width = CentimetersToPoints(16.03)
        .WrapFormat.AllowOverlap = True
        .WrapFormat.Side = wdWrapNone
        .WrapFormat.Type = 3
        .RelativeHorizontalPosition = _
        wdRelativeVerticalPositionMargin
        .RelativeVerticalPosition = _
        wdRelativeVerticalPositionMargin
        .Left = wdShapeCenter
        .Top = wdShapeCenter
    End With
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

Please leave your comments or queries under comment section also please do subscribe to our blogs to keep your self upto date.

Leave a Reply

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