General discussion

Locked

About setting word header and footer.

By iamcto ·
How can I use other document's header and footer to current document? For example, if I open A.doc then it will automatically use the header and footer of B.doc. I tried to save B.doc as normal.dot, but it's just effective when I creat a new document but not work when I open an exist document.How can I make it effective on exist document?

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by BFilmFan In reply to About setting word header ...

With Word 2000 and 2003, you could use cut and paste for the headers and then save that document as a template.

Collapse -

by iamcto In reply to

Thank you for your help. So there is no way to automatically use other doc's(or template's) header or footer except manually copy and paste?

Collapse -

by DKlippert In reply to About setting word header ...

In the source document, highlight the Header text. Go to Insert Bookmark and give it a name. Do the same for the Footer.
In the target document use the IncludeText field.
The code may look like:
{INCLUDETEXT "test.doc" Header1 \* MERGEFORMAT}

(the brackets can not be inserted by hand. Use Insert>Field or Ctrl+F9

Collapse -

by iamcto In reply to

Thank you for your help, I tested it, if the header only include the text then the result is right but now my header include text and picture. I wonder if it is possible to write a macro to finish this work?

Collapse -

by DKlippert In reply to About setting word header ...

If you are going to use the same header each time, you could seleect the text and the graphic. Go to Insert>AutoText New.
Give the selection a unique name "Head1"
Now when you type Head1 and hit enter, the AutoText will be inserted.

Collapse -

by iamcto In reply to

DKlippert, thank you very much and happy new year!
Because the header and footer often change, I plan to write a macro with VBA to finisth this work. My solution is copy header and footer from A.doc to B.doc. Now I met a question, how can I select the header then copy it? Below is my part script:
With ActiveDocument.ActiveWindow.View (1)
.SeekView = wdSeekFirstPageHeader(2)
End With (3)
Selection.WholeStory (4)
Selection.Copy (5)
but this script has compile error at statement(2), could you kindly help me to realize the function?

Collapse -

by ManISKid In reply to About setting word header ...

I think that editing the html/xml that word documents are created from may work to use a style sheet or form of some sort

Collapse -

by iamcto In reply to

Now, I have created a macro to copy header and footer.For your informationm, the script is as below. But when I run the script, I found a question that the height of footer and header areas are different with original, How can i keep them unchanged?

Sub change_header()

Dim ls_docname, ls_tempname As String
Dim ttopmargin, tbottommargin, tleft, tright As Double
ls_docname = ActiveDocument.Name

Documents.Open FileName:="d:\ta.dot"

ttopmargin = Selection.PageSetup.topmargin
tbottommargin = Selection.PageSetup.bottommargin
tleft = Selection.PageSetup.LeftMargin
tright = Selection.PageSetup.RightMargin

Documents(ls_docname).Activate
ActiveDocument.PageSetup.topmargin = ttopmargin
ActiveDocument.PageSetup.bottommargin = tbottommargin
ActiveDocument.PageSetup.LeftMargin = tleft
ActiveDocument.PageSetup.RightMargin = tright


Documents("Ta.dot").Activate


ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Copy

Documents(ls_docname).Activate
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete
Selection.PasteAndFormat (wdFormatOriginalFormatting)

Documents("Ta.dot").Activate
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.WholeStory
Selection.Copy

Documents(ls_docname).Activate
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.WholeStory
Selection.Delete
Selection.PasteAndFormat (wdFormatOriginalFormatting)

Documents("Ta.dot").Activate
ActiveDocument.Close

End Sub

Back to Software Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums