View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ibvalentine ibvalentine is offline
external usenet poster
 
Posts: 25
Default Omit header from first page without embedding header in code

I want to print a multi-page worksheet omitting the header on the first page.
However, I also want to create a macro to do this without embedding the
header info in the code. I do not know VBA programming, but I have been
reading some web sites and playing around with it.

Here's a solution that I thought would work (maybe it just needs some
tweaking):

Sub NoFirstPageHeader_AllSheets()
Dim wsSheet As Worksheet
Dim sHeader As String
For Each wsSheet In Worksheets
With wsSheet
sHeader = .PageSetup.LeftHeader
.PageSetup.LeftHeader = ""
sHeader = .PageSetup.CenterHeader
.PageSetup.CenterHeader = ""
sHeader = .PageSetup.RightHeader
.PageSetup.RightHeader = ""
.PrintOut From:=1, To:=1
sHeader = .PageSetup.LeftHeader
sHeader = .CenterHeader
sHeader = .RightHeader
.PrintOut From:=2
End With
Next wsSheet
End Sub

The problem is that this code deletes my header entirely instead of what I
intended it to do (omit the header on the first page). I tried to replace
"PageSetup" with "Print" but that, of course, did not work. I am surprised
that doing a simple thing like omitting the header on the first page is such
a big deal.

I have come up with a few workarounds, but if anyone knows of a macro that
can do what I described, please let me know. Again, the sticky part is that I
want this to work in any workbook with different page headers.

Thanks!