Help with modifying VB6 Code to insert page numbers in Word Document - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help with modifying VB6 Code to insert page numbers in Word Document

HelenSurridgeHelenSurridge Posts: 1Member

I have an application which wrote a report to Word 2002. I have just upgraded to Word 2007 and the report fails. I have traced this to the line which is trying to insert the page number at the bottom. This is how the code looked:

Sub CreateFooter()
wdapp.ActiveWindow.View.Type = wdPageView
wdapp.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
wdapp.Selection.Font.Name = "Arial"
wdapp.Selection.Font.Size = 12
wdapp.Selection.Font.bold = True
wdapp.Selection.TypeText Text:="Issued By:" & vbTab & "Date: """
wdapp.NormalTemplate.AutoTextEntries("- PAGE -").Insert wdapp.Selection.Range
wdapp.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

The line that fails is:

wdapp.NormalTemplate.AutoTextEntries("- PAGE -").Insert wdapp.Selection.Range

Does anyone know the equivalent for Word 2007 which will correctly insert the page numbers in the footer?

Many thanks for any help you can give!!


Sign In or Register to comment.