Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Automating Page Header

I have this in the before print:

vDate = Range("C4").Value
vName = Range("C5").Value
ActiveSheet.PageSetup.LeftHeader = "Expense Report" & Chr(10) & vDate &
Chr(10) & vName

Question: How do I tell it only print the Header if Page Number is greater
than 1.

Thank you for your help.

Steven.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Automating Page Header

Steven,

To the best of my knowledge it is not possible to set a flag (similar to
word) to print a different header on the first page.

But you can, as you rightly say, use the beforeprint event as follows:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
On Error GoTo resume_pos
Dim sz_Header As String
Dim vDate As Variant
Dim vName As Variant

Cancel = False
Application.EnableEvents = False
vDate = ActiveSheet.Range("C4").Value
vName = ActiveSheet.Range("C5").Value
sz_Header = "Expense Report" & Chr(10) & vDate & Chr(10) & vName

ActiveSheet.PageSetup.LeftHeader = ""
ActiveSheet.PrintOut From:=1, To:=1
ActiveSheet.PageSetup.LeftHeader = sz_Header
ActiveSheet.PrintOut From:=2
resume_pos:
Application.EnableEvents = True
End Sub

You need to disable the enableevents while the operation is performed and
reset it afterwards.

If you are debuging the and stop the code the enableevents is not reset so
itis useful to have the following macro to reset it:

Public Sub setenableeventstrue()
Application.EnableEvents = True
End Sub

--
HTHs Martin Fishlock


"Steven" wrote:

I have this in the before print:

vDate = Range("C4").Value
vName = Range("C5").Value
ActiveSheet.PageSetup.LeftHeader = "Expense Report" & Chr(10) & vDate &
Chr(10) & vName

Question: How do I tell it only print the Header if Page Number is greater
than 1.

Thank you for your help.

Steven.

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
Omit header from first page without embedding header in code ibvalentine Excel Worksheet Functions 6 August 28th 07 05:10 AM
Get header only on first page of multi page excel file betwms Excel Discussion (Misc queries) 3 March 29th 06 05:47 PM
Automating Word - Print one page not entire document! quartz[_2_] Excel Programming 1 January 25th 05 06:16 PM
Automating the downloading of web page and sending it via email Sean[_7_] Excel Programming 1 May 24th 04 02:55 PM
Page Header with Fit to 1 page wide Josh Smith[_2_] Excel Programming 0 July 15th 03 09:51 PM


All times are GMT +1. The time now is 10:22 AM.

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"