Update Page Number in cell for Print Area

engpe

New Member
Joined
Feb 29, 2012
Messages
1
Hello all,

I would like to be able to update the page number in a repeating print area and have a single printout command to produce a single pdf file. The print area is fixed and I know the number of pages (3). There is a cell where the user can input the first page number to be used.

Here is the code that I have been using.

Sub PrintPages()

Dim NumSheets As Double, FirstPageNum As Double, SheetNumOutput As Range

Set SheetNumOutput = myWorksheet.Range("I2")
NumSheets = 3
FirstPageNum = myWorksheet.Cells(11, 11) 'User inputs first page number.

For n = 1 To NumSheets
SheetNumOutput.Value = FirstPageNum + n - 1
myWorksheet.PrintOut n, n, 1, True
Next n

End Sub

The problem is that when I try to print to a pdf, I get separate printout for each page. I would like to have this functionality while printing to only one pdf file. This code works when I print to a regular printer, but not to a pdf creator.

Thanks,

Jeremy
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,823
Messages
6,121,780
Members
449,049
Latest member
greyangel23

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