VBA Printing Custom Footer on all but last page

  • Thread starter Thread starter Caruna
  • Start date Start date
C

Caruna

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.
 
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
 
Back
Top