VBA Export to PDF adding blank pages

davec1234

New Member
Joined
Nov 26, 2014
Messages
1
Hi,
For the life of me I cannot figure this out.
I have created an invoicing spreadsheet which extracts data from a database and populates my invoices. Each invoice is of a varying length depending on the number of entries.
Using VBA I have calculated the bottom row of the invoice (which is working perfectly) yet when I export my invoices to PDF they have anywhere from 1 to 4 blank pages at the end.

Although it doesnt make a huge difference, my invoices are correct, this little quirk is driving me mad! Any ideas?

This is my code to print the invoices.

Workbooks(ThisFile).Sheets(ThisClient).Activate
ActiveSheet.Range("A1:P" & (BottomRow)).ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFilename
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Have you checked how many pages would print off normally if you printed your file in excel?
Check page break preview and have a look and see how many pages there are and adjust the area accordingly.
Else take a look at what your BottomRow is set to...
 
Upvote 0

Forum statistics

Threads
1,223,941
Messages
6,175,537
Members
452,652
Latest member
eduedu

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