View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Unable to set the LeftHeader property of the PageSetup class

Try this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets(1).PageSetup.LeftHeader = "&""Arial,Bold""""Client No. """ & _
Worksheets(1).Range("ClientNum1").Value
Worksheets(2).PageSetup.LeftHeader = "&""Arial,Bold""''Client No.'' " & _
Worksheets(2).Range("ClientNum2").Value
Worksheets(3).PageSetup.LeftHeader = "&""Arial,Bold""''Client No. ''" & _
Worksheets(3).Range("ClientNum3").Value
End Sub





"John" wrote:

I keep getting the following message:
"Unable to set the LeftHeader property of the PageSetup class". I'm trying
to reference a cell value in the header with the following
WorkBook_BeforePrint event code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("1").PageSetup.LeftHeader = "&""Arial,Bold""Client No. " &
Worksheets("1").Range("ClientNum1").Value
Worksheets("2").PageSetup.LeftHeader = "&""Arial,Bold""Client No. " &
Worksheets("2").Range("ClientNum2").Value
Worksheets("3").PageSetup.LeftHeader = "&""Arial,Bold""Client No. " &
Worksheets("3").Range("ClientNum3").Value
End Sub

The print precedure (partial) is:

Sub Test()
Worksheets("1").Range("Page1").PrintOut
End Sub

The WorkBook_BeforePrint event fails when I call the Test procedure. Why??
When I print preview, it assigns the range value to the header properly,
which tells me the WorkBook_BeforePrint code is correct.

Please note that I have named my sheets numbers