InfoChase
asked on
Creating a macro in Excel 2007 to auto repeat rows, except the last page, and send to pdf instead of print.
I got this code from another EE answer. Playing with it, and not sure I understand the line marked with **.
ALSO, the macro works, but not exactly what I'm looking for. It does the auto repeat rows in Excel and allows me to change the auto repeat rows for the last page correctly. BUT, I want to create a .pdf when I run the macro instead of sending out a print job.
How can I tweak to make this happen. Code follows:
Sub PrintTest()
'macro written by nutsch on 4/23/08, with lots of inspiration from http://www.rondebruin.nl/print.htm
Dim TotPages As Long
**TotPages = application.ExecuteExcel4M acro("GET. DOCUMENT(5 0)")
With ActiveSheet
.PageSetup.PrintTitleRows = "$1:$7"
.PrintOut From:=1, To:=TotPages - 1
.PageSetup.PrintTitleRows = "$1:$6"
.PrintOut From:=TotPages, To:=TotPages
End With
End Sub
ALSO, the macro works, but not exactly what I'm looking for. It does the auto repeat rows in Excel and allows me to change the auto repeat rows for the last page correctly. BUT, I want to create a .pdf when I run the macro instead of sending out a print job.
How can I tweak to make this happen. Code follows:
Sub PrintTest()
'macro written by nutsch on 4/23/08, with lots of inspiration from http://www.rondebruin.nl/print.htm
Dim TotPages As Long
**TotPages = application.ExecuteExcel4M
With ActiveSheet
.PageSetup.PrintTitleRows = "$1:$7"
.PrintOut From:=1, To:=TotPages - 1
.PageSetup.PrintTitleRows = "$1:$6"
.PrintOut From:=TotPages, To:=TotPages
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you hv a chance to try the proposed solution ?
gowflow
gowflow
ASKER
The code worked, but not exactly what I needed. The situational need has passed, and I do not need to pursue this issue any further. Thanks for the assist; the code, and the idea, may be useful for some other situation down the road.
Your welcome, let me put a samll comment here. You may not need the code now as you mentioned 'The situational need has passed' and it is understood however this does not remove the fact that it was a total working solution as it happens that I use this specific code in my software developped to clients. Furthermore you confirmed that the solution worked (but it was not exactly what you needed)
All this being said, do you feel that it is fair that you rated this question B ?
gowflow
All this being said, do you feel that it is fair that you rated this question B ?
gowflow
TotPages = Application.ExecuteExcel4M
Will return in the variable TotPages the number of pages to be printed.
As far as creating a .pdf question is: on your pc how do you create a .pdf do you use pdf995 as printer and print to it and then it create the pdf or ... ? based on your answer will advise next step.
gowflow