ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Only Printing Header on First Page (https://www.excelbanter.com/excel-programming/349989-only-printing-header-first-page.html)

beans_21[_3_]

Only Printing Header on First Page
 

Hi,

I'm currently using the Workbook Before Print function to add a header
on to my sheet, but every sheet spans two pages. Is there a way of only
printing the header on the first page? Any help would be great! :)

Dave


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696


Ron de Bruin

Only Printing Header on First Page
 
hi

Check out
http://www.rondebruin.nl/print.htm#Header

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


"beans_21" wrote in message
...

Hi,

I'm currently using the Workbook Before Print function to add a header
on to my sheet, but every sheet spans two pages. Is there a way of only
printing the header on the first page? Any help would be great! :)

Dave


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696




beans_21[_4_]

Only Printing Header on First Page
 

Thats great and does exactly what I want thanks!!! But there is one
problem! I'm wanting to put that code on the Before Print function, so
what happens is that it prints with the header on the first page and
then not on the second, but then it prints again if you see what i mean
so is there any way of cancelling the second print from coming out?

Thanks,

Dave :)


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696


Ron de Bruin

Only Printing Header on First Page
 
Hi Beans

You can use Cancel = true
This example is for "Sheet1" and you must copy it into the thisworkbook module

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False

MsgBox "copy your code here"

Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub


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


"beans_21" wrote in message
...

Thats great and does exactly what I want thanks!!! But there is one
problem! I'm wanting to put that code on the Before Print function, so
what happens is that it prints with the header on the first page and
then not on the second, but then it prints again if you see what i mean
so is there any way of cancelling the second print from coming out?

Thanks,

Dave :)


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696




beans_21[_5_]

Only Printing Header on First Page
 

I can't seem to get it working, I'm quite new to this so it is prob me
being silly, I've attached my code, can you see what I am doing wrong?
It's now just printing one copy off but not with the header :mad: !

Thanks a lot for your help :)

Dave


Code:
--------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveWorkbook.Name = "Equipment_Booking_v5.2" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False

MsgBox "Your Code Here"
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")

With ActiveSheet.PageSetup
.PrintArea = "$b$2:$az$90"
.Orientation = xlLandscape
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.BlackAndWhite = False
.PrintErrors = xlPrintErrorsDisplayed
.FitToPagesWide = False
.zoom = 55
.CenterHeader = "&U&26Bookings Week Commencing " & (Application.ActiveSheet.Name)
ActiveSheet.PrintOut From:=1, To:=1
.CenterHeader = ""
ActiveSheet.PrintOut From:=2, To:=TotPages
End With

'turn off page breaks
ActiveSheet.DisplayAutomaticPageBreaks = False

Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
--------------------


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696


Ron de Bruin

Only Printing Header on First Page
 
Hi

If ActiveWorkbook.Name = "Equipment_Booking_v5.2" Then


You must test the sheet here and not the workbook (see my example)




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


"beans_21" wrote in message
...

I can't seem to get it working, I'm quite new to this so it is prob me
being silly, I've attached my code, can you see what I am doing wrong?
It's now just printing one copy off but not with the header :mad: !

Thanks a lot for your help :)

Dave


Code:
--------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveWorkbook.Name = "Equipment_Booking_v5.2" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False

MsgBox "Your Code Here"
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")

With ActiveSheet.PageSetup
.PrintArea = "$b$2:$az$90"
.Orientation = xlLandscape
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.BlackAndWhite = False
.PrintErrors = xlPrintErrorsDisplayed
.FitToPagesWide = False
.zoom = 55
.CenterHeader = "&U&26Bookings Week Commencing " & (Application.ActiveSheet.Name)
ActiveSheet.PrintOut From:=1, To:=1
.CenterHeader = ""
ActiveSheet.PrintOut From:=2, To:=TotPages
End With

'turn off page breaks
ActiveSheet.DisplayAutomaticPageBreaks = False

Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
--------------------


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696




beans_21[_6_]

Only Printing Header on First Page
 

Yep you were right, thanks again! :)

Sure you know whats coming now - any way of doing it for the work book
as the sheets names are changing all the time!

Thank you, thank you, thank you


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696


Ron de Bruin

Only Printing Header on First Page
 
If you remove

If ActiveSheet.Name = "Sheet1" Then

And the

End If

It will run your code in the activesheet.
Don't know if that is what you want ?


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


"beans_21" wrote in message
...

Yep you were right, thanks again! :)

Sure you know whats coming now - any way of doing it for the work book
as the sheets names are changing all the time!

Thank you, thank you, thank you


--
beans_21
------------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...o&userid=30281
View this thread: http://www.excelforum.com/showthread...hreadid=499696




beans_21[_7_]

Only Printing Header on First Page
 

Yes that works! You are a legend! Thank you so MUCH!!! Thats ace! Yo
rock thank you!!

Dave
:) :) :) :) :) :) :

--
beans_2
-----------------------------------------------------------------------
beans_21's Profile: http://www.excelforum.com/member.php...fo&userid=3028
View this thread: http://www.excelforum.com/showthread.php?threadid=49969



All times are GMT +1. The time now is 03:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com