J
jkorchok
Here is a little code nugget to do custom page number formatting. The
parameters .FirstPage and .Position work as expected, but the .Type
parameter (which is supposed to indicate Header or Footer placement)
is interpreted as Dialogs(wdDialogInsertPageNumbers).Type. This
returns the code for wdDialogInsertPageNumbers (294) instead of
whether the user chose Header(0) or Footer(1). There are quite a few
dialogs that use Type as a parameter. How do you access it?
Thanks!
John Korchok
Dim InsPageNums As Dialog
Set InsPageNums = Dialogs(wdDialogInsertPageNumbers)
If InsPageNums.Show = -1 Then
With InsPageNums
If .Type = 0 Then
If .FirstPage = True Then
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).PageNumbers.Add
PageNumberAlignment:=.Position, FirstPage:=True
ActiveDocument.Sections(4).Headers(wdHeaderFooterFirstPage).PageNumbers.Add
PageNumberAlignment:=.Position, FirstPage:=False
End If
ActiveDocument.Sections(4).Headers(wdHeaderFooterPrimary).PageNumbers.Add
PageNumberAlignment:=.Position, FirstPage:=False
End If
End With
End If
parameters .FirstPage and .Position work as expected, but the .Type
parameter (which is supposed to indicate Header or Footer placement)
is interpreted as Dialogs(wdDialogInsertPageNumbers).Type. This
returns the code for wdDialogInsertPageNumbers (294) instead of
whether the user chose Header(0) or Footer(1). There are quite a few
dialogs that use Type as a parameter. How do you access it?
Thanks!
John Korchok
Dim InsPageNums As Dialog
Set InsPageNums = Dialogs(wdDialogInsertPageNumbers)
If InsPageNums.Show = -1 Then
With InsPageNums
If .Type = 0 Then
If .FirstPage = True Then
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).PageNumbers.Add
PageNumberAlignment:=.Position, FirstPage:=True
ActiveDocument.Sections(4).Headers(wdHeaderFooterFirstPage).PageNumbers.Add
PageNumberAlignment:=.Position, FirstPage:=False
End If
ActiveDocument.Sections(4).Headers(wdHeaderFooterPrimary).PageNumbers.Add
PageNumberAlignment:=.Position, FirstPage:=False
End If
End With
End If