Reputation: 1
What I tried:
I attempted to retrieve the value from the RightHeader
in VBA using the following code:
Sub GetRightHeaderValue()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets(1)
Dim headerValue As String
headerValue = ws.PageSetup.RightHeader
MsgBox "RightHeader Value: " & headerValue
End Sub
The MsgBox
displayed &8&P
, but this doesn't seem to be the actual data I need.
What I expected:
I expected the RightHeader
to return the real, meaningful value, such as formatted text or numbers, rather than &8&P
. I need help decoding or interpreting this output to retrieve the actual value.
RightHeader
Upvotes: 0
Views: 103
Reputation: 4708
To get the number of pages of a worksheet (Activesheet as an example below) use
Activesheet.PageSetup.Pages.Count
Upvotes: 0
Reputation: 1586
If the header info is about total number of pages, you can use;
MsgBox Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
Upvotes: 1