Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Etijian
 
Posts: n/a
Default 1st page only Headers & Footers


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   Report Post  
Ron de Bruin
 
Posts: n/a
Default

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   Report Post  
Etijian
 
Posts: n/a
Default


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   Report Post  
Ron de Bruin
 
Posts: n/a
Default

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
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
If I change page margins headers don't line up??? CGINUSA Excel Discussion (Misc queries) 2 June 25th 05 12:54 PM
Pre-set headers and footers for new worksheets robertwesley Excel Discussion (Misc queries) 4 April 27th 05 11:14 AM
adding a new page break to an existing page break Edward Letendre Excel Discussion (Misc queries) 1 March 6th 05 09:29 AM
Better support for dynamic content within headers and footers Anvil Scott Excel Discussion (Misc queries) 1 December 21st 04 08:33 PM
In Excel, can I copy Headers and Footers between Worksheets? Brian Excel Worksheet Functions 1 November 12th 04 01:14 PM


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

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

About Us

"It's about Microsoft Excel"