J
jharris
I have some vba code in Word 2003 to automatically add a watermark to
a document through a macro button.
I have adjusted it to work with Word 2007, but it adds a header space
to the top of each page.
If I manually add the watermark it does not create the header space at
the top, only when I add the watermark via the macro.
Here is the code:
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
"C:\MS logo\em new logo2.png", LinkToFile:=False,
SaveWithDocument:=True) _
.Select
Selection.ShapeRange.Name = "WordPictureWatermark6034789"
Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = InchesToPoints(0.59)
Selection.ShapeRange.Width = InchesToPoints(1.1)
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapNone
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.Left = 455
Selection.ShapeRange.Top = 5
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey Unit:=wdStory
ActiveDocument.Protect Password:="mslegal", NoReset:=False,
Type:= _
wdAllowOnlyFormFields
a document through a macro button.
I have adjusted it to work with Word 2007, but it adds a header space
to the top of each page.
If I manually add the watermark it does not create the header space at
the top, only when I add the watermark via the macro.
Here is the code:
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
"C:\MS logo\em new logo2.png", LinkToFile:=False,
SaveWithDocument:=True) _
.Select
Selection.ShapeRange.Name = "WordPictureWatermark6034789"
Selection.ShapeRange.PictureFormat.Brightness = 0.5
Selection.ShapeRange.PictureFormat.Contrast = 0.5
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = InchesToPoints(0.59)
Selection.ShapeRange.Width = InchesToPoints(1.1)
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapNone
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.Left = 455
Selection.ShapeRange.Top = 5
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey Unit:=wdStory
ActiveDocument.Protect Password:="mslegal", NoReset:=False,
Type:= _
wdAllowOnlyFormFields