Question
5394 views

Outlook: FileDialog object error

M_K_M asked on

Am writing a small routine in Outlook 2010 vba. Intension routine is for users to select the location (folder) where they want to save selected messages. To do the job I I want to use the FileDialog object. The routine looks:

 

Public Sub ....
    Dim fdFolder As Office.FileDialog
    Set fdFolder = Application.FileDialog(msoFileDialogFolderPicker)
...............
End Sub
  

I get an error on row: Set fdFolder .....

(Runtime error 438. Object doesn't support this property or method)

 

Reference to Office Object Library is ok.

 

What is wrong?

6 people had this question

Abuse history


The answered status icon Answer
E.J. GUN replied on

Here's a really awkward workaround, but it might give you an idea of how to do what you want.  Since Outlook doesn't seem to support the FileDialog object, use one of the other Office apps as a "surrogate".

HTH,

Eric

 

'=========== BEGIN CODE ===========

Public Sub TestFileDialog()
    Dim otherObject As Excel.Application
    Dim fdFolder As office.FileDialog

    Set otherObject = New Excel.Application
    otherObject.Visible = False
    Set fdFolder = otherObject.Application.FileDialog(msoFileDialogFolderPicker)
    fdFolder.Show
    Debug.Print fdFolder.SelectedItems(1)
    otherObject.Quit
    Set otherObject = Nothing
End Sub

If this post is helpful or answers the question, please mark it so.
6 people found this helpful

Abuse history


progress