Deleting a Picture in a header

A

Ailish

Hi

I have inserted a picture in my header and filled it to the full page size.
I have also set it to sit behind the text.

I am now trying to select and delete the picture through VBA code. I can
access the header but when I try to select the picture it won't work. I have
also tried using:

ActiveDocument.InLineShapes.Count

To identify if word can even identify the picture but it comes back with
zero, it this beside the active document does not consider the header and
footer.

Help!!!

Thanks
Ailish
 
S

StevenM

Ailish,

I have a suggestion, it doesn't answer your question directly, but I always
put pictures in a one-row-one-column table. If you inserted a table into your
header (using a "None" border so that the table will not print), and put your
picture in that table, you could delete the picture simply by deleting the
table. For example:

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Delete

I got it to work for me.

Steven Craig Miller
 
D

Dylan

I think you need to refer to inlineshapes. Amending StevenM's response, you
could try:

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes(1).Delete
 
S

StevenM

:

<< the only problem is it won't fill to the top of the page and ideas >>

I'm not for sure I'm following you here. What won't fill to the top of the
page? Do you mean the picture/table will not go to the top of the page? If
so, you probably need to check: File -> Page Setup -> Margins (tab) & From
Edge & Header, change that value to zero. That will allow the table to go to
the top of the page.

While you're at it, you might also want to check the Table Properties ->
Options and the default cell margins. Normally a table has a default margin
for the left and right sides of a cell.

Steven Craig Miller
 
S

StevenM

To: Dylan,

Very good, I was hoping someone would reply with the correct answer.

Steven Craig Miller
 

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