G
graham_s
Hi,
I have copied some code that previously wrote to a Word doc page to write to
the page header. The code below is as far as I have got as there are some
problems.
1. The font.bold and font.size do not work
2. The copy and paste of the logo.bmp does not work
3. The tabstops are at different spacings compared to those when set on a
'normal' page
4. The line does not draw.
Can anyone help?
I would appreciate learning the best way to achieve this as my VBA word
knowledge is minimal (as evidenced by the code below!).
Thanks
Graham
////
code
Sub PrintStandardHeaderMSwordHeader(mobjWord As Object, RegisteredUser, _
Project, _
jobno, _
Subject, _
Calcby)
' Called from PrintCalcSheetHeader()
With mobjWord.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
..Paragraphs.tabstops.Add position:=370 ' 72 points/inch
If FileExists(App.Path & "\userlogo.bmp") Then
Clipboard.Clear
Clipboard.SetData LoadPicture(App.Path & "\userlogo.bmp") ' Get bitmap.
.Paste
.text = vbTab
Clipboard.Clear
Else
.font.Name = "arial"
.font.SIZE = 14
.font.Bold = True
.text = RegisteredUser & vbTab
End If
..font.SIZE = 11
..font.Bold = False
..insertafter "Vol. . . . . . "
..insertafter " Sec . . . . ." & vbCrLf
..insertafter "PROJECT : "
..insertafter Project & vbTab
..insertafter "Sheet . . . . . . of . . . . ." & vbCrLf
..insertafter "SUBJECT : "
..insertafter Subject & vbTab
..insertafter "Job No : "
..insertafter jobno & vbCrLf
..Paragraphs.tabstops(1).Clear
..Paragraphs.tabstops.Add position:=100
..Paragraphs.tabstops.Add position:=230
..Paragraphs.tabstops.Add position:=350
..insertafter "Calc by : "
..insertafter Calcby & vbTab
..insertafter "Date : "
..insertafter Format(Now, "dd-mmm-yy") & vbTab
..insertafter "Checked : " & vbTab
..insertafter "Date :" & vbCrLf
' draw a line under the header
..Paragraphs(1).tabstops.clearall
..Paragraphs.tabstops.Add position:=490
..font.underline = True
..insertafter vbTab
..font.underline = False
End With
End Sub
I have copied some code that previously wrote to a Word doc page to write to
the page header. The code below is as far as I have got as there are some
problems.
1. The font.bold and font.size do not work
2. The copy and paste of the logo.bmp does not work
3. The tabstops are at different spacings compared to those when set on a
'normal' page
4. The line does not draw.
Can anyone help?
I would appreciate learning the best way to achieve this as my VBA word
knowledge is minimal (as evidenced by the code below!).
Thanks
Graham
////
code
Sub PrintStandardHeaderMSwordHeader(mobjWord As Object, RegisteredUser, _
Project, _
jobno, _
Subject, _
Calcby)
' Called from PrintCalcSheetHeader()
With mobjWord.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
..Paragraphs.tabstops.Add position:=370 ' 72 points/inch
If FileExists(App.Path & "\userlogo.bmp") Then
Clipboard.Clear
Clipboard.SetData LoadPicture(App.Path & "\userlogo.bmp") ' Get bitmap.
.Paste
.text = vbTab
Clipboard.Clear
Else
.font.Name = "arial"
.font.SIZE = 14
.font.Bold = True
.text = RegisteredUser & vbTab
End If
..font.SIZE = 11
..font.Bold = False
..insertafter "Vol. . . . . . "
..insertafter " Sec . . . . ." & vbCrLf
..insertafter "PROJECT : "
..insertafter Project & vbTab
..insertafter "Sheet . . . . . . of . . . . ." & vbCrLf
..insertafter "SUBJECT : "
..insertafter Subject & vbTab
..insertafter "Job No : "
..insertafter jobno & vbCrLf
..Paragraphs.tabstops(1).Clear
..Paragraphs.tabstops.Add position:=100
..Paragraphs.tabstops.Add position:=230
..Paragraphs.tabstops.Add position:=350
..insertafter "Calc by : "
..insertafter Calcby & vbTab
..insertafter "Date : "
..insertafter Format(Now, "dd-mmm-yy") & vbTab
..insertafter "Checked : " & vbTab
..insertafter "Date :" & vbCrLf
' draw a line under the header
..Paragraphs(1).tabstops.clearall
..Paragraphs.tabstops.Add position:=490
..font.underline = True
..insertafter vbTab
..font.underline = False
End With
End Sub