Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]() I would not be suprised at all to discover that someone has already addressed this, however, I've been digging around for several hours and haven't found it yet. :) I am attempting to modify an Excel workbook so that the center header prints only on the first page and the center footer only prints on the first page. Both the header and footer consist only of a graphic, nothing else. I need it to print only on the 1st page whether I'm printing just the first page of one sheet, or a couple of pages of one sheet, or the entire workbook. I have found some code online and from friends, but it never seems to work correctly. Either that, or I'm pasting it in incorrectly. I've been fighting with this for weeks, please help me! ![]() Thanks in advance - E -- Etijian ------------------------------------------------------------------------ Etijian's Profile: http://www.excelforum.com/member.php...o&userid=25845 View this thread: http://www.excelforum.com/showthread...hreadid=392282 |
#2
![]() |
|||
|
|||
![]()
Hi
Only possible with code http://www.rondebruin.nl/print.htm#Header -- Regards Ron de Bruin http://www.rondebruin.nl "Etijian" wrote in message ... I would not be suprised at all to discover that someone has already addressed this, however, I've been digging around for several hours and haven't found it yet. :) I am attempting to modify an Excel workbook so that the center header prints only on the first page and the center footer only prints on the first page. Both the header and footer consist only of a graphic, nothing else. I need it to print only on the 1st page whether I'm printing just the first page of one sheet, or a couple of pages of one sheet, or the entire workbook. I have found some code online and from friends, but it never seems to work correctly. Either that, or I'm pasting it in incorrectly. I've been fighting with this for weeks, please help me! ![]() Thanks in advance - E -- Etijian ------------------------------------------------------------------------ Etijian's Profile: http://www.excelforum.com/member.php...o&userid=25845 View this thread: http://www.excelforum.com/showthread...hreadid=392282 |
#3
![]() |
|||
|
|||
![]() I do realize that it requires VB coding, and I have made a little progress since my last post. First, I have determined that I don't need to be able to print only specific pages, but I do need to print just a currently active worksheet. I've found some sample code for that, but it still doesn't seem to limit it only to the active sheet. The code that I'm pasting below is what I have right now. When someone clicks the Print button it prints every worksheet in the workbook, but it does do the headers and footers correctly. The only thing I need to fix now, is to make it print only the currently active worksheet, instead of the entire workbook. Here is the code: Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim wsSheet As Worksheet Dim sFooter As String Dim sHeader As String Cancel = False Application.EnableEvents = False For Each wsSheet In ActiveWindow.SelectedSheets With wsSheet If .Name = "My Sheet" Then sFooter = .PageSetup.CenterFooter sHeader = .PageSetup.CenterHeader .PrintOut From:=1, To:=1 .PageSetup.CenterFooter = "" .PageSetup.CenterHeader = "" .PrintOut From:=2 .PageSetup.CenterFooter = sFooter .PageSetup.CenterHeader = sHeader Else .PrintOut End If End With Next wsSheet Application.EnableEvents = True End Sub -- Etijian ------------------------------------------------------------------------ Etijian's Profile: http://www.excelforum.com/member.php...o&userid=25845 View this thread: http://www.excelforum.com/showthread...hreadid=392282 |
#4
![]() |
|||
|
|||
![]()
Try this for the activesheet only
Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim wsSheet As Worksheet Dim sFooter As String Dim sHeader As String Cancel = True Application.EnableEvents = False With ActiveSheet sFooter = .PageSetup.CenterFooter sHeader = .PageSetup.CenterHeader PrintOut From:=1, To:=1 .PageSetup.CenterFooter = "" .PageSetup.CenterHeader = "" .PrintOut From:=2 .PageSetup.CenterFooter = sFooter .PageSetup.CenterHeader = sHeader End With Application.EnableEvents = True End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Etijian" wrote in message ... I do realize that it requires VB coding, and I have made a little progress since my last post. First, I have determined that I don't need to be able to print only specific pages, but I do need to print just a currently active worksheet. I've found some sample code for that, but it still doesn't seem to limit it only to the active sheet. The code that I'm pasting below is what I have right now. When someone clicks the Print button it prints every worksheet in the workbook, but it does do the headers and footers correctly. The only thing I need to fix now, is to make it print only the currently active worksheet, instead of the entire workbook. Here is the code: Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim wsSheet As Worksheet Dim sFooter As String Dim sHeader As String Cancel = False Application.EnableEvents = False For Each wsSheet In ActiveWindow.SelectedSheets With wsSheet If .Name = "My Sheet" Then sFooter = .PageSetup.CenterFooter sHeader = .PageSetup.CenterHeader PrintOut From:=1, To:=1 PageSetup.CenterFooter = "" PageSetup.CenterHeader = "" PrintOut From:=2 PageSetup.CenterFooter = sFooter PageSetup.CenterHeader = sHeader Else PrintOut End If End With Next wsSheet Application.EnableEvents = True End Sub -- Etijian ------------------------------------------------------------------------ Etijian's Profile: http://www.excelforum.com/member.php...o&userid=25845 View this thread: http://www.excelforum.com/showthread...hreadid=392282 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
If I change page margins headers don't line up??? | Excel Discussion (Misc queries) | |||
Pre-set headers and footers for new worksheets | Excel Discussion (Misc queries) | |||
adding a new page break to an existing page break | Excel Discussion (Misc queries) | |||
Better support for dynamic content within headers and footers | Excel Discussion (Misc queries) | |||
In Excel, can I copy Headers and Footers between Worksheets? | Excel Worksheet Functions |