Inserting autotext (picture) into a Header

S

Sol Apache

Hello
I am trying to put a picture into a first page header then its footer. I can
do this manually, but cannot get it to work via VBA. The pictures are in
autotext in the attached template.

At first I had bookmarks but all the macro would do was delete the bookmarks
so I left them out and deleted the reference to the bookmarks since it will
be only the pictures in the header and footer.

Here is the code I am using

Sub LS01()
ActiveDocument.AttachedTemplate.AutoTextEntries(³LSO1 H²).Insert _
Where:=ActiveDocument.Sections(1)(wdHeaderFooterFirstPage).Range

[similar for footer]

End sub

Can anyone let me know what I am doing wrong in this code?

Thanks for any help




Sol
 
S

Stefan Blom

ActiveDocument.AttachedTemplate.AutoTextEntries("LSO1 H").Insert _
Where:=ActiveDocument.Sections(1)(wdHeaderFooterFirstPage).Range

Well, .Headers is missing from the code (unless you've simply left it
out when pasting/typing into the newsgroup message):

ActiveDocument.AttachedTemplate.AutoTextEntries("LSO1 H").Insert _
Where:=ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage) _
..Range

Also, and perhaps more importantly, since you are inserting into a
first page header, did you remember to enable the "Different first
page" option in File | Page Setup? In code, this would be done via:

ActiveDocument.Sections(1).PageSetup _
..DifferentFirstPageHeaderFooter = True

--
Stefan Blom
Microsoft Word MVP


in message
Hello
I am trying to put a picture into a first page header then its footer. I can
do this manually, but cannot get it to work via VBA. The pictures are in
autotext in the attached template.

At first I had bookmarks but all the macro would do was delete the bookmarks
so I left them out and deleted the reference to the bookmarks since it will
be only the pictures in the header and footer.

Here is the code I am using

Sub LS01()
ActiveDocument.AttachedTemplate.AutoTextEntries(³LSO1 H²).Insert _
Where:=ActiveDocument.Sections(1)(wdHeaderFooterFirstPage).Range

[similar for footer]

End sub

Can anyone let me know what I am doing wrong in this code?

Thanks for any help




Sol
 
S

Sol Apache

Yes, I did leave out ³headers² for the newsgroup; it¹s in the original code.
And, yes, I have set up my template with a different first page.

So there is nothing wrong with my code? Why, then, is it not working? It
won¹t put anything in the footer either, but it was doing something because
it would delete the bookmarks I had there though I did not tell it to.

VB is getting a mind of its own??

Thx

Sol
 
S

Sol Apache

Well, I¹ve found out what is wrong: Microsoft has shortchanged us Mac users
again.

The macro works fine on Windows.
 
S

Stefan Blom

I'm glad you've found an explanation (though not a solution). Did you
report this in a Word Mac newsgroup?
 
S

Sol Apache

No I haven¹t reported it yet because I have been too busy doing these
templates.

Thanks
 

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