FileDialog Object on a User Form

G

Gamini Jayarathne

Hi ,

I am creating a COM Add-in using VBA Add-in designer. I have created a user
form to get some custom properties of a shape. In there I am trying to use
the FileDialog object to a File name as a property. The following code does
not work as expected.
The Error I get is " Invalid use of Property". But all the code samples
given are same as mine. Is it somthing that I haven't set a particular
refernce????

Private Sub cmdBrowse_Click()
Dim fd As Office.FileDialog

Dim vrtSelectedItem As Variant

fd = Application.FileDialog(msoFileDialogFilePicker)

With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
Set txtURL.Value = vrtSelectedItem
Next vrtSelectedItem
Else
End If
End With

Set fd = Nothing

End Sub
 
P

Peter Suter

Hi

Try again with set!

set fd = Application.FileDialog(msoFileDialogFilePicker)

Ok now?

Peter


Hi ,

I am creating a COM Add-in using VBA Add-in designer. I have created a
user
form to get some custom properties of a shape. In there I am trying to
use
the FileDialog object to a File name as a property. The following code
does
not work as expected.
The Error I get is " Invalid use of Property". But all the code samples
given are same as mine. Is it somthing that I haven't set a particular
refernce????

Private Sub cmdBrowse_Click()
Dim fd As Office.FileDialog

Dim vrtSelectedItem As Variant

fd = Application.FileDialog(msoFileDialogFilePicker)

With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
Set txtURL.Value = vrtSelectedItem
Next vrtSelectedItem
Else
End If
End With

Set fd = Nothing

End Sub

--
Regards

Peter Suter
Ing.
CH 3255 Rapperswil BE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top