From: Caruna on
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
From: Gord Dibben on
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 <Caruna(a)discussions.microsoft.com>
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.

From: Caruna on
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