tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,832
- Office Version
- 365
- 2019
- Platform
- Windows
The code below saves Sheet1 and Sheet2 as a single pdf.
The problem is there are big spaces on the page around the sides. In page preview in Excel, it maximises the use of the page but not when it's a pdf.
How can I change this?
Thanks
Code:
With ThisWorkbook
Dim SaveFile As Variant
SaveFile = Application.GetSaveAsFilename(InitialFileName:=Left(String:=.FullName, _
Length:=(InStrRev(StringCheck:=.FullName, StringMatch:=".", Start:=-1, Compare:=vbTextCompare) - 1)) & ".pdf", FileFilter:="PDF files, *.pdf", _
Title:="Save workbook as pdf")
With Sheet1.PageSetup
.PrintArea = "$A$1:$R$50"
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
With Sheet2.PageSetup
.PrintArea = "$A$1:$S$60"
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
.Worksheets(Array(Sheet1.Name, Sheet2.Name)).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=SaveFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=True, _
OpenAfterPublish:=False
End With
Next Counter
The problem is there are big spaces on the page around the sides. In page preview in Excel, it maximises the use of the page but not when it's a pdf.
How can I change this?
Thanks