Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation and watermarks

Status
Not open for further replies.

BTon15

Programmer
Nov 21, 2001
29
0
0
GB
I'm doing Word Automation from VB6 (using Word 2000) and need to display a watermark in my Word doc, but only under certain circumstances.

Does anyone know if Word watermarks can be made visible/hidden programmatically from VB, or do I need to use 2 templates (one with a watermark and one without)?

Thanks in advance for any help,

John
 
To solve these type of problems I use the Macro recorder, then Cut/Paste/Modify as needed.

Sub AddWM()
'
' AddWM Macro
' Macro recorded 24/07/2003 by John M
'
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes.AddPicture(FileName:= _
"C:\Documents and Settings\My Documents\My Pictures\fred.gif", _
LinkToFile:=False, SaveWithDocument:=True).Select
Selection.ShapeRange.Name = "WordPictureWatermark1"
Selection.ShapeRange.PictureFormat.Brightness = 0.85
Selection.ShapeRange.PictureFormat.Contrast = 0.15
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = CentimetersToPoints(18.9)
Selection.ShapeRange.Width = CentimetersToPoints(14.65)
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 = wdShapeCenter
Selection.ShapeRange.Top = wdShapeCenter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Sub RemWM()
'
' RemWM Macro
' Macro recorded 24/07/2003 by John M
'
ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.Shapes("WordPictureWatermark1").Select
Selection.Delete
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top