Finding named shapes in headers/footers

R

Roderick O'Regan

I have a document in Word 2002 with a number of sections and I want to
place a graphic in the header of each section. The graphic is the same
one but the section headers are, deliberately, not linked to the
previous ones.

To do this I have created code which goes into the header and rotates
through each section doing something like the following:

With ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range,
Filename:= _
"C:\MyTemplates\colourTopBar.jpg", LinkToFile:=False, _
SaveWithDocument:=True)
.Select
.Name = "Header Graphic" + strSections
End With

Through coding I've added the variable strSections which, hopefully,
is naming each graphic in each header with Header Graphic1, Header
Graphic2, etc.

The coding I've used to insert them seems to work OK.

The problem is that when I then go into the Headers of each section
and give the command:
ActiveDocument.Shapes("Header Graphic1).Delete
....it tells me that that shape does not exist.

Therefore (1) Am I doing the naming procedure correctly? If I am then
(2) Why cannot VBA find and delete it?

Can anyone help please?

Regards

Roderick
 

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