Delete WordArt from Header

J

Jules

I have set up a macro to insert a file in each section/page of a header.

The code is:

Dim s As Section
For Each s In ActiveDocument.Sections
s.Headers(wdHeaderFooterPrimary).Range.InsertFile
FileName:="p:\w2000\a\water.doc"
s.Headers(wdHeaderFooterEvenPages).Range.InsertFile
FileName:="p:\w2000\a\water.doc"
s.Headers(wdHeaderFooterFirstPage).Range.InsertFile
FileName:="p:\w2000\a\water.doc"
Next s

The file "p:\w2000\a\water.doc" inserts a WordArt object that is used as a
wartermark.

This code works perfectly and inserts the watermark/wordart into each
section/page of the document.

I would like to be able to set up a macro to delete the "watermark/wordart".
The only thing I have found is
s.headers(wdheaderfooterfirstpage).range.delete (as set up above for first,
primary and even page headers).

This code deletes all of the header, not just the watermark/wordart.

How would I set up the code to only delete the watermark/wordart and not the
rest of the header?

thanks,
 
S

Stefan Blom

Assuming that the WordArt is *not* positioned "In line with text", you can
use the following:

Sub DeleteInsertedWordArts()
Dim s As Section
Dim j As Shape
For Each s In ActiveDocument.Sections
For Each j In s.Headers(wdHeaderFooterPrimary).Shapes
If j.Type = 15 Then
j.Delete
End If
Next j

For Each j In s.Headers(wdHeaderFooterEvenPages).Shapes
If j.Type = 15 Then
j.Delete
End If
Next j

For Each j In s.Headers(wdHeaderFooterFirstPage).Shapes
If j.Type = 15 Then
j.Delete
End If
Next j
Next s
End Sub

The above code does not remove any other objects that may be anchored to the
header (such as text boxes).

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 
J

Jules

Thank you very very very much. This is great.

Stefan Blom said:
Assuming that the WordArt is *not* positioned "In line with text", you can
use the following:

Sub DeleteInsertedWordArts()
Dim s As Section
Dim j As Shape
For Each s In ActiveDocument.Sections
For Each j In s.Headers(wdHeaderFooterPrimary).Shapes
If j.Type = 15 Then
j.Delete
End If
Next j

For Each j In s.Headers(wdHeaderFooterEvenPages).Shapes
If j.Type = 15 Then
j.Delete
End If
Next j

For Each j In s.Headers(wdHeaderFooterFirstPage).Shapes
If j.Type = 15 Then
j.Delete
End If
Next j
Next s
End Sub

The above code does not remove any other objects that may be anchored to the
header (such as text boxes).

--
Stefan Blom
Microsoft Word MVP


in message
 

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