R
R. Choate
I have a large app in Word that calls a letterhead template file to apply letterhead on the 1st page. Once I finally got that
working, a new problem cropped up. When the letter is longer than one page, I have some code (shown below) for applying certain
information in the header on the 2nd page. Now, instead of getting that, I'm getting the entire first page of the letter repeated in
the 2nd page header. None of the stuff I want in the 2nd page header shows up. Here is my code for the 2nd page header. It is in a
sub by itself:
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
Please help. I finally got the letterhead working but I can't have this new problem ruin everything. Here is the code which calls
the letterhead template:
'starts new document
strPath = "C:\Documents and Settings\Administrator\Desktop\"
strName = "Letterhead template.dot"
Documents.Add Template:=strPath & strName, _
NewTemplate:=False, _
DocumentType:=wdNewBlankDocument, _
Visible:=True
working, a new problem cropped up. When the letter is longer than one page, I have some code (shown below) for applying certain
information in the header on the 2nd page. Now, instead of getting that, I'm getting the entire first page of the letter repeated in
the 2nd page header. None of the stuff I want in the 2nd page header shows up. Here is my code for the 2nd page header. It is in a
sub by itself:
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
Please help. I finally got the letterhead working but I can't have this new problem ruin everything. Here is the code which calls
the letterhead template:
'starts new document
strPath = "C:\Documents and Settings\Administrator\Desktop\"
strName = "Letterhead template.dot"
Documents.Add Template:=strPath & strName, _
NewTemplate:=False, _
DocumentType:=wdNewBlankDocument, _
Visible:=True