I googled a tweak for the mac version of GetSaveAsFilename, but it was wanting to prompt the user to first resave the whole excel workbook with a new name before making the pdf, and it also didn't seem to work when I tested it on a Mac anyway. I can navigate Macs, so maybe it did work, but it never opened my PDF file, and I couldn't figure out if it had created it.
The code below works perfectly on my PC, but I need it to work for Mac users. The first part of the code is just creating the page setup: landscape orientation and narrow margins. I hope that works on a Mac.
The second part of the code is to save the print area as a PDF with the user creating the name of the PDF file. This does not compute on a Mac.
Could someone please advise how I could add a line that says IfPC do the code I have, If Mac, do this.....?
The code below works perfectly on my PC, but I need it to work for Mac users. The first part of the code is just creating the page setup: landscape orientation and narrow margins. I hope that works on a Mac.
The second part of the code is to save the print area as a PDF with the user creating the name of the PDF file. This does not compute on a Mac.
Could someone please advise how I could add a line that says IfPC do the code I have, If Mac, do this.....?
Code:
Sub Printrange1()
ActiveSheet.PageSetup.PrintArea = "$A$2:$K$25"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
Application.PrintCommunication = True
Dim FName As Variant
FName = Application.GetSaveAsFilename( _
FileFilter:="PDF files, *.pdf", _
Title:="Export to pdf")
If FName <> False Then
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End If
End Sub