Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Unable to set the LeftHeader property of the PageSetup class

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






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Unable to set the LeftHeader property of the PageSetup class

By any chance are you getting error 1004? I wonder if you have a named
range called "Page1".
--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"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







  #3   Report Post  
Posted to microsoft.public.excel.programming
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







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

John, I thought you needed more quote marks, but actually you did not after I
took a closer look. I put your code in my ThisWorkbook module and used the
print button. I substituted a cell reference for your range reference but it
printed the header without sending a message. I also set up a print command
in the standard module in VBA to print all three pages and it put the headers
on without sending a message. I cannot duplicate your error. I assume,
since you use quote marks on your sheet numbers that you have named the
sheets "1", "2" and "3". If not, the quotes should be removed.

"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







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Unable to set the LeftHeader property of the PageSetup class

As I read this again, I wonder if your events are enabled. But then, it
shouldn't trigger at all if they aren't. I tried something similar and the
beforeprint ran when I did a ActiveSheet.printout.
--
HTH,
Barb Reinhardt




"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









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Unable to set the LeftHeader property of the PageSetup class

I did some googling and found some comments relative to new printers. Are
you still using the same printer? Also, what version of Excel are you
having a problem with.

"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







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default Unable to set the LeftHeader property of the PageSetup class

Hi,

Take a look at the following, it may pertain to your situation:

http://support.microsoft.com/kb/291298/en-us

If this helps, please click the Yes button.
--
Thanks,
Shane Devenshire


"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







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Unable to set the LeftHeader property of the PageSetup class

I appreciate all the help. I still get the error message. I'm using Excel
2007, and I have printer drivers installed. And yes, it is run time error
1004. Frustrating...



"Barb Reinhardt" wrote in message
...
I did some googling and found some comments relative to new printers. Are
you still using the same printer? Also, what version of Excel are you
having a problem with.

"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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to set the Orientation property of the PageSetup class Aero[_2_] Excel Programming 1 March 17th 06 01:03 PM
Help - Error: Unable to set the PrintArea property of the PageSetup class Marie J-son[_5_] Excel Programming 3 January 5th 05 02:04 PM
Unable to set the PaperSize property of the PageSetup class [email protected] Excel Programming 2 November 22nd 04 03:43 PM
Unable to Set LeftFooter Property Class PageSetup (ASP) fredlankovich Excel Programming 0 June 23rd 04 07:56 PM
Unable to set the PrintQuality property of the PageSetup class. No Name Excel Programming 1 January 14th 04 04:43 PM


All times are GMT +1. The time now is 11:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"