Add Watermark macro - Variable not defined

T

tammy.djuric

I'm trying to write a macro which will allow operators to create their
own watermarks using Word 2003. I've recorded a macro to insert a
draft watermark but when I run the recorded macro back it fails at the
third line with a message "Variable not defined" and
PowerPlusWatermarkObject1 highlighted. It fails when I run it on a new
document as well. The recorded code is below.

ActiveDocument.Sections(1).Range.Select
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

Selection.HeaderFooter.Shapes.AddTextEffect(PowerPlusWaterMarkObject1,
_
"COPY", "Times New Roman", 1, False, False, 0, 0).Select
Selection.ShapeRange.Name = "PowerPlusWaterMarkObject1"
Selection.ShapeRange.TextEffect.NormalizedHeight = False
Selection.ShapeRange.Line.Visible = False
Selection.ShapeRange.Fill.Visible = True
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(192, 192, 192)
Selection.ShapeRange.Fill.Transparency = 0.5
Selection.ShapeRange.Rotation = 315
Selection.ShapeRange.LockAspectRatio = True
Selection.ShapeRange.Height = CentimetersToPoints(6.89)
Selection.ShapeRange.Width = CentimetersToPoints(13.78)
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

Any suggestions greatly appreciated.

Tammy
 
H

Helmut Weber

Hi Tammy,

I don't know what unexplainable stuff
the macrorecorder is recording.

Instead of PowerPlusWaterMarkObject1 try
using a MsoPresetTextEffect-constant, like:

selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1, _
"ASAP", "Times New Roman", 1, False, False, 0, 0).Select

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tony Jollans

A couple of points ...

* What will your macro offer that the built-in dialog doesn't? Unless
it's significant, don't try because ...

* The macro recorded code for creating watermarks in Word 2002 and 2003
really doesn't work.

* Trying to duplicate what actually happens with these watermarks is very
difficult and you will not normally end up with anything as robust.
 
T

tammy.djuric

Thanks Tony, we need to be able to lock down the format of the
watermarks and also provide the ability for operators to type in text
not in the dropdown list to use as watermarks.

cheers,
Tammy
 
D

Doug Robbins - Word MVP

Most probably caused by linebreaks occuring in the wrong place as in

Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1,
_
"Update", "Times New Roman", 1, False, False, 0, 0).Select

Place the cursor in front of the " before Update and use the backspace key
until you have

......(msoTextEffect1, "Update", ..etc.

Likewise for any other lines of code that appear in red font.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top