I have an excel template that I have created that will create a word document via macros and send different pieces of information to the word document depending on the options chosen. It is working well but I can't seem to add page numbers to the Word doc from the Excel macro. Help!
This is what I have to create the word doc to prepare it for data. It works but I really want to add page numbers to it.
'Create object definitions for MS Word
Set appWD = CreateObject("Word.Application")
' Tell Word to create a new document and format it
Set appWD = New Word.Application
appWD.Documents.Add
appWD.Visible = True
zzWord_Format_Portrait
Sub zzWord_Format_Portrait()
With appWD.Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.Gutter = Application.InchesToPoints(0)
.HeaderDistance = Application.InchesToPoints(0.5)
.FooterDistance = Application.InchesToPoints(0.5)
.PageWidth = Application.InchesToPoints(8.5)
.PageHeight = Application.InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
End With
End Sub
This is what I have to create the word doc to prepare it for data. It works but I really want to add page numbers to it.
'Create object definitions for MS Word
Set appWD = CreateObject("Word.Application")
' Tell Word to create a new document and format it
Set appWD = New Word.Application
appWD.Documents.Add
appWD.Visible = True
zzWord_Format_Portrait
Sub zzWord_Format_Portrait()
With appWD.Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.Gutter = Application.InchesToPoints(0)
.HeaderDistance = Application.InchesToPoints(0.5)
.FooterDistance = Application.InchesToPoints(0.5)
.PageWidth = Application.InchesToPoints(8.5)
.PageHeight = Application.InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
End With
End Sub