J
Jcericola
I wrote a simple macro to add a watermark to my document. Now I'm trying to
write one to delete the watermark. The code works on the first Watermark I
insert and delete, but subsequent ones give me an error "The item with the
specified name was not found". I beleive the problem is that word wants to
reference the object by name, but if the name of the item is different
everytime you reinsert a new watermark. Please help me find a way to delete
my watermark. Here is my code. It is the second macro that fails.
Sub InsertWatermark_Draft()
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
Application.DisplayAutoCompleteTips = True
NormalTemplate.AutoTextEntries("Watermark_Draft").Insert
Where:=Selection. _
Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Sub RemoveWatermark_Draft()
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
Selection.HeaderFooter.Shapes("Text Box 2").Select
Selection.ShapeRange.Delete
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub
write one to delete the watermark. The code works on the first Watermark I
insert and delete, but subsequent ones give me an error "The item with the
specified name was not found". I beleive the problem is that word wants to
reference the object by name, but if the name of the item is different
everytime you reinsert a new watermark. Please help me find a way to delete
my watermark. Here is my code. It is the second macro that fails.
Sub InsertWatermark_Draft()
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
Application.DisplayAutoCompleteTips = True
NormalTemplate.AutoTextEntries("Watermark_Draft").Insert
Where:=Selection. _
Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Sub RemoveWatermark_Draft()
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
Selection.HeaderFooter.Shapes("Text Box 2").Select
Selection.ShapeRange.Delete
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub