Printing page # of #

Lighting

New Member
Joined
Apr 10, 2002
Messages
11
Had to go to work on Sunday to test it out. Couldn't wait till tommorrow.

daleyman, your solution worked, but as some rows got deleted and pagecount changes it still prints 7 pages. I got for example page 7 of 4. So it didn't suite me completly. Thanks anyway.

Jay Petrulis macro was just what I needed. It worked perfectly. Thanks.
Can you please explain what the following means and do?

Dim Pagecount as Integer
Dim PageNumber as Integer
PageCount=ExecuteExcel4Macro("Get.Document(50)")

And I bother you a little more.
Can you please add a code that let me choose how many copies I want to print.
Thanks in advance.

Lighting
 
On 2002-01-14 17:52, Lighting wrote:
Had to go to work on Sunday to test it out. Couldn't wait till tommorrow.

daleyman, your solution worked, but as some rows got deleted and pagecount changes it still prints 7 pages. I got for example page 7 of 4. So it didn't suite me completly. Thanks anyway.

Jay Petrulis macro was just what I needed. It worked perfectly. Thanks.
Can you please explain what the following means and do?

Dim Pagecount as Integer
Dim PageNumber as Integer
PageCount=ExecuteExcel4Macro("Get.Document(50)")

And I bother you a little more.
Can you please add a code that let me choose how many copies I want to print.
Thanks in advance.

Lighting

Hi,

The following prompts you for the number of copies you would like to print.

Sub InsertPageNumData()

Dim Pagecount As Integer
Dim PageNumber As Integer
Dim NumCopies As Integer

NumCopies = Application.InputBox("Enter the number of copies you would like", , 1)
With ActiveSheet
Pagecount = ExecuteExcel4Macro("Get.Document(50)")
For PageNumber = 1 To Pagecount
.Range("D4") = "Page " & PageNumber & " of " & Pagecount
.PrintOut From:=PageNumber, To:=PageNumber, Copies:=NumCopies
Next PageNumber
.Range("D4").ClearContents
End With
End Sub

For your other questions, the DIM statements are short for Dimension, as you set these to allocate memory to the variable. It also forces the variable to be an integer in this case.

The Excel4 macro is a throwback to the days before VBA. These functions are still available, although I don't have a full list.

This particular one finds the number of pages in the range (akin to clicking Print Preview).

Bye,
Jay
This message was edited by Jay Petrulis on 2002-04-15 08:00
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top