![]() |
|
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Indianapolis
Posts: 80
|
I'm convinced I've seen this addressed here before, but my searches revealed nothing. Sorry if this is a duplicate question.
We access files that we are not allowed to modify or resave. However, we need to print certain pages of them. These pages are all located on one worksheet. The number of printed pages depends on how many lines are in the sheet. I always need pages 1 and 2, and then the last two... n and (n-1) if n=# of last page. Also, we always setup the pages for landscape 60% and a footer of page 1 of #. I want to write a macro that will do this automatically... I think I can figure out the landscape, 60% and footer, but how do I get to what "n" is? What I do now (manually) is page preview and print 1 to 2 and when that prints, it says printing 1 of 63 or whatever and then I know to print 62 to 63. Thanks in advance for any help. I've searched Excel help, vb help and the jaywalk book I have, but am still stumped. Lisa |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
The following determines the number of pages and assigns to a variable called PageCount PageCount = ExecuteExcel4Macro("Get.Document(50)") I believe that this, as posted, will work for a single worksheet tab only. It can be modified to handle the entire workbook, so please post back if this is not sufficient. Bye, Jay |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Indianapolis
Posts: 80
|
Thanks, Jay-
I'm wrapping up for the day, but will test it first thing in the morning. Lisa |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Location: Indianapolis
Posts: 80
|
Jay -
It works beautifully! Thanks so much. I never would have found the ExecuteExcel4Macro in a million years. I appreciate your time and insight. Lisa |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|