Palerock68
New Member
- Joined
- Apr 20, 2018
- Messages
- 6
I use first the "ActiveSheet.PageSetup", to set the paper size to A4 and then the "ExportAsFixedFormat Type:=xlTypePDF" to create the pdf. When my work sheet is formatted to be with somewhat narrower data and the paper orientation is Portrait, the PDF is correct size 210x297mm.
But if I format the data to be somewhat wider and in page setup, turn the orientation to landscape, result is a PDF file with the size of 358x253mm and I cannot find the reason for this?
As a printer, I have PDFCreator and for the landscape page setup I use the following:
Then for exporting the pdf I use following code:
All help appreciated.
But if I format the data to be somewhat wider and in page setup, turn the orientation to landscape, result is a PDF file with the size of 358x253mm and I cannot find the reason for this?
As a printer, I have PDFCreator and for the landscape page setup I use the following:
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.2)
.LeftMargin = Application.InchesToPoints(0.2)
.RightMargin = Application.InchesToPoints(0.2)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.3)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.3)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
Then for exporting the pdf I use following code:
outName = "C:\temp" + ActiveSheet.Name + "PL"
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$5"
.PrintTitleColumns = ""
.PaperSize = xlPaperA4
.CenterHeader = "&8Page &P of &N"
End With
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$5"
.PrintTitleColumns = ""
.PaperSize = xlPaperA4
.CenterHeader = "&8Page &P of &N"
End With
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
outName, Quality:=xlQualityMinimum, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
What could possibly be wrong?outName, Quality:=xlQualityMinimum, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
All help appreciated.