Ron Weston
New member
- Local time
- Today, 00:10
- Joined
- Sep 3, 2007
- Messages
- 3
As the title says, I've written code to create a word document using access vba. Everything is done, but I can't get the page numbers in - here is a snippet of the code I'm using:
oDoc.ActiveWindow.ActivePane.View.SeekView = _
wdSeekCurrentPageFooter
With oDoc.ActiveWindow.ActivePane
.Selection.Font.Size = 10
.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Selection.TypeText Text:="Page "
.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage
.Selection.TypeText Text:=" of "
.Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldNumPages
.Selection.TypeText Text:=vbTab & vbTab & _
"Printed on " & Date & " at " & Time
End With
When I run it, it stops at the line with wdFieldPage and says:
Object variable of With Block not set
Any help would be appreciated. Thanks.
oDoc.ActiveWindow.ActivePane.View.SeekView = _
wdSeekCurrentPageFooter
With oDoc.ActiveWindow.ActivePane
.Selection.Font.Size = 10
.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Selection.TypeText Text:="Page "
.Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage
.Selection.TypeText Text:=" of "
.Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldNumPages
.Selection.TypeText Text:=vbTab & vbTab & _
"Printed on " & Date & " at " & Time
End With
When I run it, it stops at the line with wdFieldPage and says:
Object variable of With Block not set
Any help would be appreciated. Thanks.