Article ID: 117411
Article Last Modified on 10/11/2006
ActiveSheet.PageSetup.FirstPageNumber = <value>where <value> is an integer from -32765 to 32767, or the word xlAutomatic.
<variable> = ActiveSheet.PageSetup.FirstPageNumberThe value returned to <variable> by this statement may be either:
Value Indicates ----------------------------------------------------------------------- A positive integer User-defined starting page number -4105 Automatically determined starting page numberNote that -4105 is the value of the built-in constant "xlAutomatic"; when the worksheet has "Auto" in its First Page Number edit box, this is the value actually stored in the FirstPageNumber property.
If ActiveSheet.PageSetup.FirstPageNumber = xlAutomatic Then
<action>
End If
The following Visual Basic code example illustrates one possible
use of this procedure.
Option Explicit
Sub CheckFirstPageNumbers()
' Dimension variables.
Dim MsgString As String, xWorksheet As Variant
' Iterate through the loop once for each worksheet in the active
' workbook.
For Each xWorksheet In ActiveWorkbook.Worksheets
' Begin making the string to be shown in the message box below.
MsgString = "The worksheet '" & xWorksheet.Name & "'"
' If the worksheet is using automatic page numbering...
If xWorksheet.PageSetup.FirstPageNumber = xlAutomatic Then
' ...complete the message string accordingly.
MsgString = MsgString & " is using automatic page " & _
"numbering."
' Otherwise...
Else
' ...complete the message string accordingly.
MsgString = MsgString & " starts its page numbers at " & _
xWorksheet.PageSetup.FirstPageNumber
End If
' Show the message.
MsgBox MsgString
Next xWorksheet ' Loop until finished.
End Sub
Additional query words: 5.00a 5.00c XL98 XL97 XL7 XL5 XL
Keywords: kbdtacode kbprb kbprogramming KB117411