User defined type not defined

aman

Registered User.
Local time
Today, 06:25
Joined
Oct 16, 2008
Messages
1,251
Hi Guys

I am getting compile error: User defined type not defined in the red line in below code.

Code:
Private Sub CommandButton1_Click()
ChooseFile
End Sub
Sub ChooseFile()

[COLOR=red]Dim fd As FileDialog[/COLOR]
Set fd = Application.FileDialog(msoFileDialogFilePicker)

'get the number of the button chosen
Dim FileChosen As Integer
FileChosen = fd.Show

If FileChosen <> -1 Then

'didn't choose anything (clicked on CANCEL)
MsgBox "You chose cancel"

Else

'display name and path of file chosen
Text0 = fd.SelectedItems(1)

End If

End Sub

Any help would be much appreciated.

Thanks
 
I suspect you have a missing reference.
 
You are missing a reference. I think the reference you need is Microsoft Office XX.X Object Library.

Where XX.X is the version number I got 14.0, yours could be 12.0 or 14.0. Add it, then compile your code again.
 
Thanks Guys. I added the object library reference and it started working. :)
 

Users who are viewing this thread

Back
Top Bottom