Reputation: 751
So i have searched for hours now and did not find a solution. I am trying to export sheets that have a print area to PDF but the PDF layout is different than what i see when i check the print preview.
i am using excel 2010.
Does anyone know why this happens.
code i use to export
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
filename:=filename, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Upvotes: 0
Views: 2108
Reputation: 751
Finally found a solution. apparently its something with the settings.
In Excel, go to File > Options > Advanced. Under General section, uncheck ‘Scale content for A4 or 8.5 x 11” paper size’ and click OK.
Upvotes: 1
Reputation: 2859
Instead of exporting the document, why dont you print the sheet and set the printer to PDF printer something like.
Sub PrintTest() ' This will print multiple sheets based on a certain criteria
Dim sh As Worksheet
Dim arr() As String
Dim i As Long: i = 0
For Each sh In ThisWorkbook.Worksheets
If Mid(sh.Name, 1, 4) = "Test" Then ' Change the conditional statement
sh.PageSetup.Orientation = xlLandscape
ReDim Preserve arr(i)
arr(i) = sh.Name
i = i + 1
End If
Next sh
Dim printSheets As Variant
printSheets = arr
Worksheets(printSheets).PrintOut Preview:=False, ActivePrinter:="Adobe PDF", PrintToFile:=True, PrToFileName:=PSFileName
End Sub
Upvotes: 0