From: tammy.djuric on 8 Oct 2006 07:59 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
From: Helmut Weber on 8 Oct 2006 14:46 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"
From: "Tony Jollans" my forename at my surname dot on 8 Oct 2006 15:52 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. -- Enjoy, Tony <tammy.djuric(a)alemy.com.au> wrote in message news:1160308799.166323.175250(a)h48g2000cwc.googlegroups.com... > 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 >
From: tammy.djuric on 8 Oct 2006 19:17 Perfect!! All working now. Thanks Helmut! Much appreciated. Helmut Weber wrote: > 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"
From: tammy.djuric on 8 Oct 2006 19:19 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 Tony Jollans wrote: > 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. > > -- > Enjoy, > Tony > > <tammy.djuric(a)alemy.com.au> wrote in message > news:1160308799.166323.175250(a)h48g2000cwc.googlegroups.com... > > 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 > >
|
Pages: 1 Prev: Languages Next: wordApp.documents.open results in error code 800A1401 on some |