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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Headers in templates

Status
Not open for further replies.

RGoldthorpe

Technical User
Aug 10, 2001
83
GB
Ok so my user imports an amipro document into word.

Using the Normal template

I the go tool-templates and addins and change the template to amipro header.dot.

Why oh Why does it not show the header.

If you use the amipro header.dot from file new it shows the header why not when you change the template.

Please help

Rach
 
Because templates don't *pull in* stuff. They only set styles, and give you the autotext or macros available in the template.

To get the headers to come in will be a bit of a bigger deal requiring VBA code, OR you can File-New, then copy/paste from AmiPro to Word.

Do the AmiPro docs have different sections in the documents? Or should they all have the one header from the template?

How many AmiPro docs do you have? Anne Troy
 
Thousands of policy documents and things

When I import the documents it leaves the headers of so have recreated the header in word atm we are importing the document and then cutting and pasting document into the amipro header document to put the headers on. but this is time consuming.

Thought there must be a quicker way?

THanks

Rach
 
There is. Using VBA code. I don't code it myself (have to pay my coder to do it for me), but there might be someone here who can.

I suggest code that will, on open a file *.sam, connect it to the template, copy the header from the template into the doc, and save it as a Word *.doc file with the same name.

Better yet, this code will loop through all the files under folder X (and its subfolders), and do this for you in one fell swoop.

Are they all the same AmiPro template? Or different? In that case, you'd want to put the SAMs in different folders and edit the code slightly to grab the appropriate templates and headers, unless there is a specific text in the SAM files that we could use to tell us which template it needs to use.... Anne Troy
 
no no they are all the same

any help for would be appreciated i have done a small amount of coding but not enough to say I can code well

Rach
 
I came across this code. Doesn't work for me, but then I may not be doing what you are.

Sub hdr()
Dim doc1 As Document

Dim doc2 As Document

Dim r1 As Range
Dim r2 As Range

Set doc1 = Documents.Open("C:\Test.dot")
Set doc2 = ActiveDocument
Set r1 = doc1.Sections(1).Headers(wdHeaderFooterPrimary).Range
Set r2 = doc2.Sections(1).Headers(wdHeaderFooterPrimary).Range

r2.FormattedText = r1.FormattedText

End Sub
 
Thankyou I will try it out and let you know what happens

Ta

Rach
 
hi

I tried it I get an error

cannot copy between these two ranges

r2.FormattedText = r1.FormattedText

any ideas
 
Horrah I got it to work

there were a few bits and pieces in the code that were the wrong way round which is why it wasn't working for reference the working code is

Sub hdr()
Dim doc1 As Document
Dim doc2 As Document

Dim r1 As Range
Dim r2 As Range

Set doc1 = ActiveDocument
Set doc2 = Documents.Open("C:\test.dot")
Set r1 = doc1.Sections(1).Headers(wdHeaderFooterPrimary).Range
Set r2 = doc2.Sections(1).Headers(wdHeaderFooterPrimary).Range

r1.FormattedText = r2.FormattedText


Thanks for all your help
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top