Use the following code to create a watermark inside Word document.
Public Shared Function CreateWaterMark(ByRef oDoc As ThisDocument, ByVal WatermarkText As String)
End Function
Public Shared Function CreateWaterMark(ByRef oDoc As ThisDocument, ByVal WatermarkText As String)
Dim wmShape As Word.Shape
'Create the watermark shape
wmShape = oDoc.Shapes.AddTextEffect( _
Microsoft.Office.Core.MsoPresetTextEffect.msoTextEffect1, _
WatermarkText, "Times New Roman", 96, False, True, 0, 0)
'Set all of the attributes of the watermark
With wmShape
.Select()
.Name = "PowerPlusWaterMarkObject1"
.TextEffect.NormalizedHeight = False
' Create a hollow text
.Line.Visible = True
.Line.ForeColor.RGB = Word.WdColor.wdColorGray25
.Fill.Visible = False
.LockAspectRatio = True
.Rotation = 315
' Positioning the watermark
.RelativeVerticalPosition = Word.WdRelativeVerticalPosition.wdRelativeVerticalPositionMargin
.RelativeHorizontalPosition = Word.WdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin
.Left = oDoc.Application.InchesToPoints(1.0)
.Top = Word.WdShapePosition.wdShapeCenter
' Wrap the text around the watermark
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = Word.WdWrapSideType.wdWrapBoth
.WrapFormat.Type = Word.WdWrapType.wdWrapNone
' Put the watermark behind the normal text
.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText)
End With
' Set focus back to document
oDoc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument
Return wmShape
End Function
Comments