8 replies
by bfilmfan
by iamcto
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?
by dklippert
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
by iamcto
by dklippert
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.
by iamcto
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?
by maniskid
by iamcto
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
This discussion is closed to new replies.
Trending Software posts
Sort by Trending