D
Denise
Hello
Using Office 2002 SP-2, Windows 2000 V5.0 SP-4.
Several of my users are experiencing a problem with a custom watermark in
Word. I created a macro to automatically add a watermark to a Word
document and it works perfectly on most machines. The watermark is
positioned centered both horizontally and vertically on the page.
On some machines, when used with a particular template which has 2
sections, the watermark appears centered in the second section but shifted
to the right in the first section. On the vast majority of machines this
does not occur and the watermark is correctly positioned.
I used the following code to create the watermark:-
Sub Watermark()
' Sometimes (randomly, apparently) setting the
RelativeHorizontalPosition
' property of the shape fails, so an 'On Error Resume Next' statement
is used.
On Error Resume Next
Dim tText As String
tText = InputBox("Note: it may take several seconds for the page
numbers " _
& "to update correctly after inserting the watermark." & Chr(13) &
Chr(13) _
& "Please enter text for watermark:", "Watermark")
If tText <> "" Then
Application.ScreenUpdating = False
' The code in this With statement just moves the cursor into
' the header (generated by the macro recorder)
With ActiveWindow
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
End If
With .ActivePane.View
If .Type = wdNormalView Or .Type = wdOutlineView Then
.Type = wdPrintView
End If
.SeekView = wdSeekCurrentPageHeader
End With
End With
' Place the shape then move it to the end of the header
With Selection
.HeaderFooter.Shapes.AddTextEffect(msoTextEffect2, tText, _
"Arial Black", 72#, msoFalse, msoFalse, 163.25,
60.25).Select
.Cut
.EndKey Unit:=wdStory
.Paste
End With
' Format the shape
With Selection.ShapeRange
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.RGB = RGB(192, 192, 192)
.Fill.Transparency = 0#
.Line.Visible = msoFalse
.LockAspectRatio = msoTrue
.Height = 329.05
.Width = 302.4
.Rotation = 0#
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = wdShapeCenter
.Top = wdShapeCenter
.LockAnchor = True
.WrapFormat.Type = wdWrapNone
End With
' Clean up
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Fields.Update
Application.ScreenUpdating = True
End If
End Sub
I confess to having just recorded a macro and then added it to Normal.dot,
but this has worked fine for most machines and I didn't really think there
was that much to it.
It may just be one of those things with Word that you just have to smile
and shake your head at but I'd appreciate any thoughts on the subject.
Thanks very much
Denise Crawley
Using Office 2002 SP-2, Windows 2000 V5.0 SP-4.
Several of my users are experiencing a problem with a custom watermark in
Word. I created a macro to automatically add a watermark to a Word
document and it works perfectly on most machines. The watermark is
positioned centered both horizontally and vertically on the page.
On some machines, when used with a particular template which has 2
sections, the watermark appears centered in the second section but shifted
to the right in the first section. On the vast majority of machines this
does not occur and the watermark is correctly positioned.
I used the following code to create the watermark:-
Sub Watermark()
' Sometimes (randomly, apparently) setting the
RelativeHorizontalPosition
' property of the shape fails, so an 'On Error Resume Next' statement
is used.
On Error Resume Next
Dim tText As String
tText = InputBox("Note: it may take several seconds for the page
numbers " _
& "to update correctly after inserting the watermark." & Chr(13) &
Chr(13) _
& "Please enter text for watermark:", "Watermark")
If tText <> "" Then
Application.ScreenUpdating = False
' The code in this With statement just moves the cursor into
' the header (generated by the macro recorder)
With ActiveWindow
If .View.SplitSpecial <> wdPaneNone Then
.Panes(2).Close
End If
With .ActivePane.View
If .Type = wdNormalView Or .Type = wdOutlineView Then
.Type = wdPrintView
End If
.SeekView = wdSeekCurrentPageHeader
End With
End With
' Place the shape then move it to the end of the header
With Selection
.HeaderFooter.Shapes.AddTextEffect(msoTextEffect2, tText, _
"Arial Black", 72#, msoFalse, msoFalse, 163.25,
60.25).Select
.Cut
.EndKey Unit:=wdStory
.Paste
End With
' Format the shape
With Selection.ShapeRange
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.RGB = RGB(192, 192, 192)
.Fill.Transparency = 0#
.Line.Visible = msoFalse
.LockAspectRatio = msoTrue
.Height = 329.05
.Width = 302.4
.Rotation = 0#
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = wdShapeCenter
.Top = wdShapeCenter
.LockAnchor = True
.WrapFormat.Type = wdWrapNone
End With
' Clean up
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Fields.Update
Application.ScreenUpdating = True
End If
End Sub
I confess to having just recorded a macro and then added it to Normal.dot,
but this has worked fine for most machines and I didn't really think there
was that much to it.
It may just be one of those things with Word that you just have to smile
and shake your head at but I'd appreciate any thoughts on the subject.
Thanks very much
Denise Crawley