Stored header information

Lauren279

Board Regular
Joined
Aug 19, 2014
Messages
95
I know you can get cell information and have it as the header and footer via vba
But what I am after is the opposite, I have a worksheet that is generated via a program and most of the information is stored in the header and footer (date, time, report name etc etc) and I need to work with the header information to call the file when a user wants to save it as a PDF

Was wondering if it is possible if there is a way extract the information in the header that is already on the worksheet in a cell or be able to save the workbook as .leftheader.value kinda like the way u would use range(“c1”).value during the save as vba
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Re: HELP with stored header information

I have this that extracts the info

Code:
Dim RLeftHeader As String
Dim RCenterHeader As String
Dim RightHeader As String
Dim RLeftFooter As String
Dim RCenterFooter As String
Dim RRightFooter As String






Sub ReadHeaderFooter()
    With ActiveSheet.PageSetup
        RLeftHeader = .LeftHeader
        RCenterHeader = .CenterHeader
        RightHeader = .RightHeader
        RLeftFooter = .LeftFooter
        RCenterFooter = .CenterFooter
        RRightFooter = .RightFooter
    End With
    Range("A1").Value = RLeftHeader
    Range("A2").Value = RCenterHeader
    Range("A3").Value = RRightHeader
    Range("A4").Value = RLeftFooter
    Range("A5").Value = RCenterFooter
    Range("A6").Value = RRightFooter
    
End Sub

I am looking at making a table that translates the fields such as &P to something meaningful.
 
Upvote 0
Re: HELP with stored header information

Sorry, made a mistake with the right header variable

Code:
Dim RLeftHeader As String
Dim RCenterHeader As String
Dim RRightHeader As String
Dim RLeftFooter As String
Dim RCenterFooter As String
Dim RRightFooter As String


Sub ReadHeaderFooter()
    With ActiveSheet.PageSetup
        RLeftHeader = .LeftHeader
        RCenterHeader = .CenterHeader
        RRightHeader = .RightHeader
        RLeftFooter = .LeftFooter
        RCenterFooter = .CenterFooter
        RRightFooter = .RightFooter
    End With
    Range("A1").Value = RLeftHeader
    Range("A2").Value = RCenterHeader
    Range("A3").Value = RRightHeader
    Range("A4").Value = RLeftFooter
    Range("A5").Value = RCenterFooter
    Range("A6").Value = RRightFooter
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top