PDA

View Full Version : Solved: VB6 an Excel Filedialog



Dave
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
.Show
'get selected file name
For Each VrtSelectedItem In .SelectedItems
FLname = VrtSelectedItem
Next
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
.Show
End With

Any help will much appreciated. Dave

Tommy
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

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