i = W.Selection.Information(wdActiveEndSectionNumber)
W.Selection.Goto What:=wdGoToSection, Which:=wdGoToFirst, count:=i, name:=""
W.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
'--------------------------------------------
'Select large font for document name
'--------------------------------------------
W.Selection.Font.name = "Arial"
W.Selection.Font.Size = 18
Fmt.TextBoldOn
'-------------------------------------
'Establish WP number from passed index
'-------------------------------------
wpNum$ = frmMain.txtWPNum(wpIdx)
'--------------------------------------------
'Write the program info to first tab position
'Include the Work Package string, no date
'--------------------------------------------
If Left$(frmMain.txtTPS.Text, 3) = "TPI" Then
W.Selection.TypeText Text:=frmMain.txtTPS.Text
Else
W.Selection.TypeText Text:="TPI " & frmMain.txtTPS.Text
End If
W.Selection.Font.name = "Arial"
W.Selection.Font.Size = 14
W.Selection.TypeText Text:=vbTab & vbTab & _
"WP " & wpNum$ & " 0" & Trim$(Str$(subWp)) & vbCrLf$
W.Selection.TypeText Text:=vbTab & vbTab & "Page "
W.Selection.Fields.Add Range:=W.Selection.Range, Type:=wdFieldPage
W.Selection.TypeText Text:=" of "
'--------------------------------------------
'Add the total number of section pages
'--------------------------------------------
If wpIdx = 7 Then
W.Selection.TypeText Text:="TPLPAGES"
W.Selection.TypeText Text:=vbCrLf$ & vbCrLf$
Else
W.Selection.Fields.Add Range:=W.Selection.Range, Type:=wdFieldEmpty, _
Text:="SECTIONPAGES ", PreserveFormatting:=True
W.Selection.TypeText Text:=vbCrLf$
End If
W.Selection.Font.Size = 16 'to get the 1.5" margin
W.Selection.TypeText Text:=vbCrLf$
With W.Selection.ParagraphFormat
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 12
.SpaceAfterAuto = False
End With
Fmt.BorderBottom 'put border after 2nd line of header
With W.Selection.HeaderFooter.PageNumbers
.NumberStyle = wdPageNumberStyleArabic
.HeadingLevelForChapter = 0
.IncludeChapterNumber = False
.ChapterPageSeparator = wdSeparatorHyphen
.RestartNumberingAtSection = True
.StartingNumber = 1
End With
Fmt.TextBoldOff ' turn off bold