Excel ExportAsPDF exports to different size on different computers

mladenjevtic

New Member
Joined
May 23, 2018
Messages
12
I wasn't able to think of the better title for my problem here.

What's going on is that i'm unable to reproduce the same export to PDF from home connection as to my office connection. We use cloud system at the office and use Citrix to connect, so in theory i should have my Windows profile settings the same, wherever i connect.
I have one macro (part of another macro) which creates bunch of PDFs using the code

VBA Code:
Public Sub ExportToPDF()
Application.StatusBar = "Printing " & ServiceOrder & " Freight Charges (" & i - 1 & " out of " & LRServiceOrders - 1 & ")"
ICAO = WorksheetFunction.VLookup(Val(ServiceOrder), shRETO.Range("TRETO"), 4, 0)

FileNamePDF = ServiceOrder & Space(1) & ICAO & " Freight charges" & ".pdf"
FolderPDF = shStart.Range("FolderPDF").Value2

shImport.Visible = xlSheetVisible

shImport.PageSetup.PrintArea = shImport.Range("A1:AF" & Rows.Count).End(xlUp)
shImport.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPDF & Application.PathSeparator & FileNamePDF, _
          quality:=xlQualityStandard, openafterpublish:=False, IgnorePrintAreas:=False

End Sub

What i don't understand is:

When i am at the office and run the macro, all PDF files are exported with really large paper sizes. When i open the exported PDF it shows that actual size is 41.77 x 29.51 inches, while i need it to be 8.26 x 11.69 inches (A4 size). But, when i log in to my account from home, and run the very same macro, it exports out just fine to PDF as A4 paper size.
I'm trying to fix the problem on all sort of ways, but i'm not able to find the solution. Question that was answered already on the link: wrong PDF output size with ExportAsFixedFormat in Excel VBA, didn't help me unfortunately. I've read bunch of forums, blogs, tutorials where i can't find why is this happening.

What can i do to reproduce the same result that i get when i log in from home?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I wonder whether the system thinks there is a different printer available and uses that to determine page settings. One thing to try is to set the "system" to use the Microsoft Print to PDF driver and then try again on both locations.
 
Upvote 0
Try adding this line...

shImport.PageSetup.PaperSize = xlPaperA4

Tried that, but still the same.

I wonder whether the system thinks there is a different printer available and uses that to determine page settings. One thing to try is to set the "system" to use the Microsoft Print to PDF driver and then try again on both locations.

I'm not sure how to set driver in VBA, do you have any reference for that?
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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