Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm working in Excel 2002.
I would like to have a header appear on the second page and the pages that follow. The text that I want printed in the header beginning on page 2 is Unit Intake Report (continued). I have tried using the following coding with no success: Sub Test() Dim TotPages As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup .LeftHeader = "" ActiveSheet.PrintOut From:=1, To:=1 .LeftHeader = "Unit Intake Report (continued)" ActiveSheet.PrintOut From:=2, To:=TotPages End With End Sub My document is protected. I've used the above coding sandwiched between: ActiveSheet.Unprotect ActiveSheet.Protect This still does not produce a header. Can I suppress the first page header within a protected document? Thanks -- Jamie |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jamie,
I just ran your exact code on a protected sheet with two pages. Ran and printed without a problem - with header printed on the second page only. (XL2002) Regards, Jim Cone San Francisco, USA "Jamie" wrote in message ... I'm working in Excel 2002. I would like to have a header appear on the second page and the pages that follow. The text that I want printed in the header beginning on page 2 is Unit Intake Report (continued). I have tried using the following coding with no success: Sub Test() Dim TotPages As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup .LeftHeader = "" ActiveSheet.PrintOut From:=1, To:=1 .LeftHeader = "Unit Intake Report (continued)" ActiveSheet.PrintOut From:=2, To:=TotPages End With End Sub My document is protected. I've used the above coding sandwiched between: ActiveSheet.Unprotect ActiveSheet.Protect This still does not produce a header. Can I suppress the first page header within a protected document? Thanks Jamie |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jim to print the document I was using the print button. One of my
coworkers pointed out that I needed to print from within the macro itself clicking on the Run Sub/User Form. Doing that the document prints out great. Thanks for your help, I appreciate it. -- Jamie "Jim Cone" wrote: Jamie, I just ran your exact code on a protected sheet with two pages. Ran and printed without a problem - with header printed on the second page only. (XL2002) Regards, Jim Cone San Francisco, USA "Jamie" wrote in message ... I'm working in Excel 2002. I would like to have a header appear on the second page and the pages that follow. The text that I want printed in the header beginning on page 2 is Unit Intake Report (continued). I have tried using the following coding with no success: Sub Test() Dim TotPages As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup .LeftHeader = "" ActiveSheet.PrintOut From:=1, To:=1 .LeftHeader = "Unit Intake Report (continued)" ActiveSheet.PrintOut From:=2, To:=TotPages End With End Sub My document is protected. I've used the above coding sandwiched between: ActiveSheet.Unprotect ActiveSheet.Protect This still does not produce a header. Can I suppress the first page header within a protected document? Thanks Jamie |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jamie,
You are welcome. A way to start the macro from the worksheet is to go to the menu bar... Tools | Macro | Macros... In the displayed list of macros, select your macro and click the "Run" button. Regards, Jim Cone San Francisco, USA "Jamie" wrote in message ... Hi Jim to print the document I was using the print button. One of my coworkers pointed out that I needed to print from within the macro itself clicking on the Run Sub/User Form. Doing that the document prints out great. Thanks for your help, I appreciate it. Jamie "Jim Cone" wrote: Jamie, I just ran your exact code on a protected sheet with two pages. Ran and printed without a problem - with header printed on the second page only. (XL2002) Regards, Jim Cone San Francisco, USA "Jamie" wrote in message ... I'm working in Excel 2002. I would like to have a header appear on the second page and the pages that follow. The text that I want printed in the header beginning on page 2 is Unit Intake Report (continued). I have tried using the following coding with no success: Sub Test() Dim TotPages As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup .LeftHeader = "" ActiveSheet.PrintOut From:=1, To:=1 .LeftHeader = "Unit Intake Report (continued)" ActiveSheet.PrintOut From:=2, To:=TotPages End With End Sub My document is protected. I've used the above coding sandwiched between: ActiveSheet.Unprotect ActiveSheet.Protect This still does not produce a header. Can I suppress the first page header within a protected document? Thanks Jamie |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jim, thanks for your help. I have another question. Can I add coding
to the macro so the user can either use the print button or File, Print. I'd like to keep them out of Tools, Macro, Macros. Also I'd like to stay away from creating a print button on the worksheet. -- Jamie "Jim Cone" wrote: Jamie, You are welcome. A way to start the macro from the worksheet is to go to the menu bar... Tools | Macro | Macros... In the displayed list of macros, select your macro and click the "Run" button. Regards, Jim Cone San Francisco, USA "Jamie" wrote in message ... Hi Jim to print the document I was using the print button. One of my coworkers pointed out that I needed to print from within the macro itself clicking on the Run Sub/User Form. Doing that the document prints out great. Thanks for your help, I appreciate it. Jamie "Jim Cone" wrote: Jamie, I just ran your exact code on a protected sheet with two pages. Ran and printed without a problem - with header printed on the second page only. (XL2002) Regards, Jim Cone San Francisco, USA "Jamie" wrote in message ... I'm working in Excel 2002. I would like to have a header appear on the second page and the pages that follow. The text that I want printed in the header beginning on page 2 is Unit Intake Report (continued). I have tried using the following coding with no success: Sub Test() Dim TotPages As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup .LeftHeader = "" ActiveSheet.PrintOut From:=1, To:=1 .LeftHeader = "Unit Intake Report (continued)" ActiveSheet.PrintOut From:=2, To:=TotPages End With End Sub My document is protected. I've used the above coding sandwiched between: ActiveSheet.Unprotect ActiveSheet.Protect This still does not produce a header. Can I suppress the first page header within a protected document? Thanks Jamie |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jamie,
You can use the "BeforePrint" event that Excel provides. If you do this every sheet in the workbook will use your code when it is printed... Jim Cone San Francisco, USA In the ThisWorkbook module add the following code: '------------------------------ Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) 'Prevent normal printing. Cancel = True 'Call the macro with printing code. PrintTest End Sub '------------------------------ '------------------------------ In a standard module add the following code... (your code with some additional lines) '------------------------------------- Option Explicit Sub PrintTest() On Error GoTo PrintError ' New line Application.EnableEvents = False ' New line Dim TotPages As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup .LeftHeader = "" ActiveSheet.PrintOut From:=1, To:=1 .LeftHeader = "Unit Intake Report (continued)" ActiveSheet.PrintOut From:=2, To:=TotPages End With PrintError: ' New line Application.EnableEvents = True ' New line End Sub '------------------------------------ '------------------------------------ "Jamie" wrote in message ... Hi Jim, thanks for your help. I have another question. Can I add coding to the macro so the user can either use the print button or File, Print. I'd like to keep them out of Tools, Macro, Macros. Also I'd like to stay away from creating a print button on the worksheet. Jamie "Jim Cone" wrote: Jamie, You are welcome. A way to start the macro from the worksheet is to go to the menu bar... Tools | Macro | Macros... In the displayed list of macros, select your macro and click the "Run" button. Regards, Jim Cone San Francisco, USA -snip- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Suppress First Page Numbering | Excel Worksheet Functions | |||
How do I suppress the Header/Footer? | Excel Discussion (Misc queries) | |||
How do you suppress the page number on page one? | Excel Discussion (Misc queries) | |||
How do I suppress a header of footer on the first page of a docume | Setting up and Configuration of Excel | |||
Suppress First Page Header | Excel Worksheet Functions |