R
R. Choate
Here is my code which sets up the header for the 2nd page if my document is longer than 1 page (this is from a template app):
MyDate = DateSerial(Year(Date), Month(Date), Day(Date))
Application.ScreenUpdating = False
With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
.Range.Fields.Add Range:=ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range, _
Type:=wdFieldEmpty, Text:="REF clientname", PreserveFormatting:=False
.Range.InsertAfter vbCr
.Range.InsertAfter Format(MyDate, "mmmm d, yyyy")
.Range.InsertAfter vbCr
.Range.InsertAfter "Page " & _
ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
.Range.Font.Size = 10
.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
End With
End Sub
Now, I'm getting the entire first page text of the actual letter repeated in the 2nd page, in the header. The stuff I want in the
2nd page header shows up below it. This code is in a sub by itself: and has worked fine for years. I've recently changed the code
which starts the letter so that it calls a template with letterhead on the 1st page only. Hopefully somebody can troubleshoot this
for me. I've spent a lot of time on this but I'm stumped. I know that the problem occurs in this sub.
Thanks !
MyDate = DateSerial(Year(Date), Month(Date), Day(Date))
Application.ScreenUpdating = False
With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
.Range.Fields.Add Range:=ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range, _
Type:=wdFieldEmpty, Text:="REF clientname", PreserveFormatting:=False
.Range.InsertAfter vbCr
.Range.InsertAfter Format(MyDate, "mmmm d, yyyy")
.Range.InsertAfter vbCr
.Range.InsertAfter "Page " & _
ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
.Range.Font.Size = 10
.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
End With
End Sub
Now, I'm getting the entire first page text of the actual letter repeated in the 2nd page, in the header. The stuff I want in the
2nd page header shows up below it. This code is in a sub by itself: and has worked fine for years. I've recently changed the code
which starts the letter so that it calls a template with letterhead on the 1st page only. Hopefully somebody can troubleshoot this
for me. I've spent a lot of time on this but I'm stumped. I know that the problem occurs in this sub.
Thanks !