PC Review


Reply
Thread Tools Rate Thread

Automating Page Header

 
 
=?Utf-8?B?U3RldmVu?=
Guest
Posts: n/a
 
      23rd Nov 2006
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 With Quote
 
 
 
 
=?Utf-8?B?TWFydGluIEZpc2hsb2Nr?=
Guest
Posts: n/a
 
      23rd Nov 2006
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header Problem (page header & report header) Eva Microsoft Access 2 23rd Oct 2009 03:46 PM
Re: Page Header and Group Header viewable in preview but won't print hoenth Microsoft Access Reports 0 19th Jul 2004 05:38 PM
subreport group header cut-off by main report page header dkingston Microsoft Access Reports 0 19th Apr 2004 09:27 PM
Supress Page Header on 1st Page of Group Header D. Mullins Microsoft Access 1 7th Mar 2004 08:07 AM
page header shows up in previous section where no header is wanted Keith Brickey Microsoft Word Document Management 0 29th Aug 2003 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:40 PM.