View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default How do I print a footer on the last page only of an excel doc?

I was using your code from below.

The code I posted is not the site code but only print the footer on the last page

Is there any way for the code to recognize the footer information that I
have typed in for the worksheet. Instead of having to type it in the line
.rightfooter = "Your Header info"


Add your header info in a cell outside you print area
You can use this value in the macro then.

Also how do you change the code so that it prints on the first page and not
on any of the remaining pages?


Sub Test2()
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
With ActiveSheet.PageSetup
.RightFooter = Range("Z1").Value
ActiveSheet.PrintOut From:=1, To:=TotPages - 1, preview:=True
.RightFooter = ""
ActiveSheet.PrintOut From:=2, To:=TotPages, preview:=True
End With
End Sub


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



"TC" wrote in message ...
Ron,
I was using your code from below.
Sub Test()
Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
With ActiveSheet.PageSetup
.RightFooter = ""
ActiveSheet.PrintOut From:=1, To:=TotPages - 1
.RightFooter = "Your Header info"
ActiveSheet.PrintOut From:=TotPages, To:=TotPages
End With
End Sub

Is there any way for the code to recognize the footer information that I
have typed in for the worksheet. Instead of having to type it in the line
.rightfooter = "Your Header info"
Also how do you change the code so that it prints on the first page and not
on any of the remaining pages?

Thanks
Tim

"Ron de Bruin" wrote:

Hi Tc

I not see code but I have this on my site
http://www.rondebruin.nl/print.htm#Header

You can do this

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


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



"TC" wrote in message ...
I have some experience with VB code but not much. Could someone please
explain what parts of this code I have to edit and enter specific information
for my worksheet to get this code to run.
Thanks
Tim