+ Reply to Thread
Results 1 to 4 of 4

1st page only Headers & Footers

  1. #1
    Registered User
    Join Date
    08-02-2005
    Posts
    2

    Exclamation 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

  2. #2
    Ron de Bruin
    Guest

    Re: 1st page only Headers & Footers

    Hi

    Only possible with code
    http://www.rondebruin.nl/print.htm#Header


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Etijian" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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. #3
    Registered User
    Join Date
    08-02-2005
    Posts
    2

    Arrow Here's what I have so far...

    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

  4. #4
    Ron de Bruin
    Guest

    Re: 1st page only Headers & Footers

    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" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1