Reputation: 21
I'm trying to open a File Dialog in Outlook via VBA. (Outlook 2010)
With the following code i get an Error:
Runtime error 438. Object doesn't support this property or method
Private Sub btn_openPST_Click()
Dim oFileDialog As FileDialog
Set oFileDialog = myAppl.FileDialog(msoFileDialogFilePicker)
With oFileDialog
.Title = "Select your PST File"
.ButtonName = "Ok"
.Show
End With
End Sub
myAppl is an Outlook.Application Object:
Dim myAppl As Outlook.Application
Set myAppl = CreateObject("Outlook.Application")
Upvotes: 2
Views: 6018
Reputation: 448
I don't think Outlook can open a file picker. I workaround is to open an Excel sheet and then open the file picker, then close the excel sheet. Try the following code, and be sure to import the "Microsoft Excel 14.0 Object Library" Reference into Outlook.
Private Sub openFDinOutlook()
Dim xlObj As Excel.Application
Dim fd As Office.FileDialog
Set xlObj = New Excel.Application
xlObj.Visible = False
Set fd = xlObj.Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Title = "Select your PST File"
.ButtonName = "Ok"
.Show
End With
xlObj.Quit
Set xlObj = Nothing
End Sub
Upvotes: 7