Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Inserting autotext (picture) into a Header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sol Apache - 20 Nov 2006 13:11 GMT
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
Stefan Blom - 20 Nov 2006 13:48 GMT
> 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

Signature

Stefan Blom
Microsoft Word MVP

> Hello
> I am trying to put a picture into a first page header then its footer. I can
[quoted text clipped - 20 lines]
>
> Sol
Sol Apache - 20 Nov 2006 14:37 GMT
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

>> ActiveDocument.AttachedTemplate.AutoTextEntries("LSO1 H").Insert _
>> Where:=ActiveDocument.Sections(1)(wdHeaderFooterFirstPage).Range
[quoted text clipped - 12 lines]
> ActiveDocument.Sections(1).PageSetup _
> .DifferentFirstPageHeaderFooter = True
Sol Apache - 20 Nov 2006 17:56 GMT
Well, I¹ve found out what is wrong: Microsoft has shortchanged us Mac users
again.

The macro works fine on Windows.

> 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.
[quoted text clipped - 25 lines]
>> ActiveDocument.Sections(1).PageSetup _
>> .DifferentFirstPageHeaderFooter = True
Stefan Blom - 21 Nov 2006 10:23 GMT
I'm glad you've found an explanation (though not a solution). Did you
report this in a Word Mac newsgroup?

Signature

Stefan Blom
Microsoft Word MVP

> Well, I¹ve found out what is wrong: Microsoft has shortchanged us Mac users
> again.
[quoted text clipped - 21 lines]
> >>
> >> ActiveDocument.AttachedTemplate.AutoTextEntries("LSO1 H").Insert _

Where:=ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage) _
> >> .Range
> >>
[quoted text clipped - 4 lines]
> >> ActiveDocument.Sections(1).PageSetup _
> >> .DifferentFirstPageHeaderFooter = True
Sol Apache - 22 Nov 2006 17:28 GMT
No I haven¹t reported it yet because I have been too busy doing these
templates.

Thanks

On 21/11/06 10:23, in article ekOcYcVDHHA.4404@TK2MSFTNGP03.phx.gbl, "Stefan
Blom" <no.spam@please.xyz> wrote:

> I'm glad you've found an explanation (though not a solution). Did you
> report this in a Word Mac newsgroup?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.