ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Printing Custom Footer on all but last page (https://www.excelbanter.com/excel-discussion-misc-queries/260459-vba-printing-custom-footer-all-but-last-page.html)

Caruna

VBA Printing Custom Footer on all but last page
 
I need to print a custom footer on all but the last printed page of a sheet.
The last page can be of varied number.I have a basic knowledge of VBA and the
macro I have written is not working very wel.
Can somebody provide me with a correct macro that will do the job so that I
can compare were I have gone wrong.
Thanks.
--
james cassidy

Gord Dibben

VBA Printing Custom Footer on all but last page
 
Revision of Ron de Bruin code from http://www.rondebruin.nl/print.htm#not

Sub Test()
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
With ActiveSheet.PageSetup
.RightFooter = "Your Header info"
ActiveSheet.PrintOut From:=1, To:=TotPages - 1
.RightFooter = ""
ActiveSheet.PrintOut From:=TotPages, To:=TotPages
End With
End Sub

Assuming TotPages = 7

ActiveSheet.PrintOut From:=1, To:=TotPages - 1 prints 1 to 6 with footer

ActiveSheet.PrintOut From:=TotPages, To:=TotPages prints 7 to 7 no footer


Gord Dibben MS Excel MVP

On Thu, 1 Apr 2010 11:12:01 -0700, Caruna
wrote:

I need to print a custom footer on all but the last printed page of a sheet.
The last page can be of varied number.I have a basic knowledge of VBA and the
macro I have written is not working very wel.
Can somebody provide me with a correct macro that will do the job so that I
can compare were I have gone wrong.
Thanks.



Caruna

VBA Printing Custom Footer on all but last page
 
thank you works well I can see the erro of my ways
--
james cassidy


"Caruna" wrote:

I need to print a custom footer on all but the last printed page of a sheet.
The last page can be of varied number.I have a basic knowledge of VBA and the
macro I have written is not working very wel.
Can somebody provide me with a correct macro that will do the job so that I
can compare were I have gone wrong.
Thanks.
--
james cassidy



All times are GMT +1. The time now is 12:50 PM.

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