Select Data Fiile

Select Data Fiile

Anonymous
Not applicable
1,603 Views
3 Replies
Message 1 of 4

Select Data Fiile

Anonymous
Not applicable

Having trouble selecting a data file from a command button on a form in Acad 2020.

The following code gives error message on theFileDiagog(msoFileDialogOpen) line

"Run-time error 438: Object doesn't support this property of method"

Tools -> References include -

Microsoft Office 16.0 Object Library

Microsoft Scripting Runtime

------------------------------

Sub UseFileDialogOpen()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount
End With
End Sub

0 Likes
Accepted solutions (2)
1,604 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor
Accepted solution

I wouldn't use the Office dialog, it requires you to load another app into memory. Just use the Windows api. See my replies in this thread, starting with post 11.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks, but it's still proving to be a struggle. I'm attempting to update code that I wrote ten years ago, and I'm out of date. Found your 2015 update in that thread in Message #44. Within the ShowOpen function, the last If-Else-Then branches into the Else part so no file selection dialog opens.

 

Tried your update in the final 2016 message #49. On the FileDials line I get the error "Compile error" User-defined type not defined".

Is there a Tools -> References that I need to include?

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Just re-read that whole thread and found what I'd missed - the class file zip for File Dialog, and the updated version. It runs well. Whoopee. Thank you.

0 Likes