Excel for Mac 2011 - Save as PDF to given filepath

Using Excel for Mac 2011 I have created a single page report that i want to save as a pdf using a macro.  I want to save to a folder called "Report" on the desktop.  On a PC i can use the GetOpenFilename command to select the folder and then the code will create a file with a specific filename (taken from a cell within the sheet).  I am having trouble doing this on a mac however - i know there is some commentary online about this matter but i have so far been unsuccessful.  
2 questions:
How to specify the filepath
VBA syntax for creating the pdf
Help and guidance would be appreciated.
Profile-Chart-Mac-PDF.xlsm
JohnNZExcelAsked:
Who is Participating?
 
Rgonzo1971Commented:
Hi,

Pls try
Sub SavePDFMacro() 
    Dim folderPath As String
    Dim RootFolder As String

    On Error Resume Next
    RootFolder = MacScript("return (path to desktop folder) as String")
    'Or use RootFolder = "Macintosh HD:Users:YourUserName:Desktop:TestMap:"
    folderPath = MacScript("(choose folder with prompt ""Select the folder""" & _
    "default location alias """ & RootFolder & """) as string")
    On Error GoTo 0

    If folderPath <> "" Then
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ 
            folderPath &  ":" & Range("A1").Value, Quality:= _ 
            xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ 
            OpenAfterPublish:=True 
    End If
End Sub

Open in new window

for reference
http://www.rondebruin.nl/mac/mac017.htm

Regards
0
 
bbaoIT ConsultantCommented:
it seems not only you looking for a universal way to select a file using macro in Excel for both Windows and Mac.

first you need to apply all updates and patches for Excel 2011 for Mac, then if below discussion for details.

http://stackoverflow.com/questions/12263016/is-there-a-mac-pc-variant-of-application-getopenfilename
0
 
bbaoIT ConsultantCommented:
FYI - official how-to article

Programmatically Selecting Files in Excel for Windows and Excel for the Mac
https://msdn.microsoft.com/en-us/library/office/hh710200(v=office.14).aspx
0
 
JohnNZExcelAuthor Commented:
Problem solved and knowledge gained.  Created 2 procedures: 1 using the mac script to choose a folder and the other to save to a predetermined folder in the documents area.  Many thanks to the gurus.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.