View Full Version : Solved: VB6 an Excel Filedialog

04-14-2009, 11:45 AM
Can't seem to get the right VB6 syntax to open an Excel file dialog. Here's what works in XL VBA...

With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
'get selected file name
For Each VrtSelectedItem In .SelectedItems
FLname = VrtSelectedItem
End With

This doesn't work in VB6 (automation error)...

Dim ObjExcel As Object
Set ObjExcel = CreateObject("EXCEL.APPLICATION")
With ObjExcel.FileDialog(fileDialogType:=msoFileDialogfilepicker)
.AllowMultiSelect = False
End With

Any help will much appreciated. Dave

04-14-2009, 02:13 PM
You will need to add a reference to the Microsoft Office 12.0 libary for the msoFileDialogfilepicker

EDIT: Changed 11.0 to 12.0 Tommy

04-14-2009, 08:33 PM
Thanks Tommy. That works much better. It is 11.0 for my VB6. Have a nice day. Dave