Excel Page Header doesn't update

hbrems

has no clue...
Local time
Today, 18:54
Joined
Nov 2, 2006
Messages
181
Hi all,

I've got some code to update Excel page headers in my Workbook_BeforePrint method:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ws.PageSetup.LeftHeader = ws.Range("A1").Value
End Sub

Public Sub PrintSheet()
    Worksheets("Sheet1").PrintOut
End Sub

When I run this code and go to the print preview the header is there. When I just print the sheet using ws.Printout it is not.

How do I make sure the Page Header is correctly triggered?

Many thanks!
 

Users who are viewing this thread

Back
Top Bottom