vbaoutlooksave-dialog

Is there a SaveAs dialog?


I want to save a mail attachment with a SaveAs file dialog. Is it possible to do this with VBA and Outlook?


Solution

  • I don't think Outlook will let you open a file dialog!

    An ugly but quick and functional workaround that I have used is to temporarily open an instance of Excel and use its GetSaveAsFilename method.

    Set xlApp = CreateObject("Excel.application")
    xlApp.Visible = False
    strSaveAsFilename = xlApp.GetSaveAsFilename
    xlApp.Quit
    Set xlApp = Nothing
    

    Then you can say MyAttachment.SaveAsFile(strSaveAsFilename).

    If Excel is not necessarily installed, then you can do a similar trick using Word and the FileDialog method (Word doesn't have GetSaveAsFilename). See VBA help on FileDialog for an example.

    There is probably a more elegant solution out there, but the above will work...