Print area ignored when printing to PDF on a virtual machine

oCoCarbon

New Member
Joined
Oct 11, 2010
Messages
29
I think I've found a bug in Excel, related to the print area. When I print to PDF on a VM that I don't have an open window to (using python to control Excel), the print area is ignored.

Has anyone else experienced this, and has a workaround?

Apologies for cross-posting to Stack Overflow, but it looks like I won't get an answer there. If I do, I'll share it here too.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I know nothing about using python (or any other snakes :eek: ) to control Excel.
Perhaps parameter IgnorePrintArea needs to be explicitly specified

2 ways to print only specified PrintAreas to PDF using VBA:

Rich (BB code):
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Test\c.pdf", IgnorePrintAreas:=False

ActiveSheet.PrintOut ActivePrinter:="Microsoft Print to PDF", PrintToFile:=True, PrToFileName:="C:\Test\c.pdf", IgnorePrintAreas:=False
 
Upvote 0
Thanks for the suggestions. I've already tried both with and without IgnorePrintAreas set. I'll see if there's a way to call PrintOut rather than ExportAsFixedFormat from python though.
 
Upvote 0
Solved.


This problem occurs when there isn't a default printer selected on your computer. Excel cannot set or get page setup properties.

source

Possible solution
So, Make sure that the script is running with an account that:

  1. Has at least one printer set up.
  2. Has a default printer set up - this is a must!
On the settings page for printers & scanners I had to uncheck "Let Windows manage my default printer", and then set the "Microsoft Print to PDF" printer as default.
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

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