Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding template to Word doc but header/footer don't display 1

Status
Not open for further replies.

Smoothcat74

Technical User
Aug 29, 2008
40
0
0
Hi all!

I have a simple VBA macro in Word 2010 that is designed to apply a template to an existing document. The template is simple and contains only a .jpg image in both the header and footer (to mimic the client's letterhead). However, when I apply the template to an existing document, the header/footer do not appear. If I click "Document Template" in the developer tab, I can clearly see that the current template is my custom one, but it shows no changes to the active document.

If I open a new document based on the template, the header/footer display normally. Here is my oh-so-complex code:

Code:
Sub Add_Letterhead()

ActiveDocument.AttachedTemplate = "Client_Letterhead.dotm"

End Sub
 
hi,

So, what does happen when you attach a new template to a document?

Nothing.

What? Nothing happens?

That's right: nothing happens to the document when you attach a new template (well, the document stores the fact that it is now attached to a new template, but that's it).


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Well, that explains that! Thanks for the insightful article. Would you recommend instead using a macro to set the header/footer as opposed to applying a new template? Is this easily achieved?
 


Did you READ the link? It answers that question in spades.

Please post back with the solution at which you arrive.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Click on "View", then "Header & Footer". You will see the header and footer.
 
I created two seperate macros, one that adds the images as header/footer and sets the margins accordingly, and another that removes them. Works like a charm and achieves what I was after. Thanks very much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top