K
Kerri
Hi,
I created a macro that will insert the words "Draft Copy"
into a document using WordArt. I named the object Draft1
so I could create a Delete macro that would remove
the "Draft Copy". This works great until the document is
saved, closed and then reopened. Then it can't find
the "Draft1" object in order to delete it. So how do i
make it remember the object name even after it has been
saved and closed?
I provided the code below if anyone has a suggestion.
Thank you, Kerri
Dim Draft1 As Shape
'----------------------
Sub DRAFTWaterMark()
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
Set Draft1 =
Selection.HeaderFooter.Shapes.AddTextEffect
(msoTextEffect8, _
"Draft Copy", "Times New Roman", 36#, msoFalse,
msoFalse, 226.3, 157.7)
Draft1.Select
With Selection.ShapeRange
..Fill.Visible = msoTrue
..Fill.Solid
.Fill.ForeColor.RGB = RGB(192, 192, 192)
.Fill.Transparency = 0#
.Line.Weight = 0.75
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Line.Transparency = 0#
.LockAspectRatio = msoFalse
.Height = 81.35
..Width = 360#
.Rotation = 0#
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = wdShapeCenter
.Top = wdShapeCenter
.LockAnchor = True
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapBoth
.WrapFormat.DistanceTop = InchesToPoints(0)
.WrapFormat.DistanceBottom = InchesToPoints(0)
.WrapFormat.DistanceLeft = InchesToPoints(0.13)
.WrapFormat.DistanceRight = InchesToPoints(0.13)
.WrapFormat.Type = 3
.ZOrder 5
.Shadow.Visible = msoFalse
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
'---------------------------------------------------------
Sub DeleteDraft()
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader _
Draft1.Select
Selection.ShapeRange.Delete
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
I created a macro that will insert the words "Draft Copy"
into a document using WordArt. I named the object Draft1
so I could create a Delete macro that would remove
the "Draft Copy". This works great until the document is
saved, closed and then reopened. Then it can't find
the "Draft1" object in order to delete it. So how do i
make it remember the object name even after it has been
saved and closed?
I provided the code below if anyone has a suggestion.
Thank you, Kerri
Dim Draft1 As Shape
'----------------------
Sub DRAFTWaterMark()
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
Set Draft1 =
Selection.HeaderFooter.Shapes.AddTextEffect
(msoTextEffect8, _
"Draft Copy", "Times New Roman", 36#, msoFalse,
msoFalse, 226.3, 157.7)
Draft1.Select
With Selection.ShapeRange
..Fill.Visible = msoTrue
..Fill.Solid
.Fill.ForeColor.RGB = RGB(192, 192, 192)
.Fill.Transparency = 0#
.Line.Weight = 0.75
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Line.Transparency = 0#
.LockAspectRatio = msoFalse
.Height = 81.35
..Width = 360#
.Rotation = 0#
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.Left = wdShapeCenter
.Top = wdShapeCenter
.LockAnchor = True
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapBoth
.WrapFormat.DistanceTop = InchesToPoints(0)
.WrapFormat.DistanceBottom = InchesToPoints(0)
.WrapFormat.DistanceLeft = InchesToPoints(0.13)
.WrapFormat.DistanceRight = InchesToPoints(0.13)
.WrapFormat.Type = 3
.ZOrder 5
.Shadow.Visible = msoFalse
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
'---------------------------------------------------------
Sub DeleteDraft()
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader _
Draft1.Select
Selection.ShapeRange.Delete
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub