Link to home
Start Free TrialLog in
Avatar of error_prone
error_prone

asked on

Excel 2007 Save Active Workbook as PDF Through VBA

In VBA, how do I invoke the save as dialog box with the PDF file type already selected?  I realize I can use the menu command but this is what the client wants.  So basically, with the active workbook open, the save as dialog box would pop up with the file type selected as PDF.
Avatar of David L. Hansen
David L. Hansen
Flag of United States of America image

Try this:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ 
        "P:\myPathvariable & newfilenameVariable, _ 
        Quality:=xlQualityMinimum, IncludeDocProperties:=False, IgnorePrintAreas _ 
        :=False, OpenAfterPublish:=False 

Open in new window

Avatar of error_prone
error_prone

ASKER

Like I wrote in my original post, I just want the save as dialog box prompt with the file type of PDF already selected.  I don't want to have to hardcode the file name in VBA.  The user will supply that once the dialog box opens up.  
ASKER CERTIFIED SOLUTION
Avatar of David L. Hansen
David L. Hansen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm getting a Compile Error here:
Dim path As String = Application.GetSaveAsFilename("", "All Files, *.pdf", 1, "Save File As")

Also, I noticed it says ActiveSheet.  I need it to save the entire workbook as PDF.  Will the code do that?
Ok, I fixed the syntax error, but can the code not print the document?  Other than that it works fine.
Did you get it print...if not I can help (sorry for being in and out of the office)?
Yes, I removed the first line and changed ActiveSheet to ActiveWorkbook.  I only want it to save not print.  Thanks for your help.
sure thing.