Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.GetOpenFileName Issues

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I was trying to use the following code from faq707-4114 in Access2003. When I debug the code I get an error "Method or Data member not found." associated with the .GetOpenFileName highlighted. Is there a reference that needs to be made for this to work? What am I missing.


Sub OpenSingleFile()
Dim Filter As String, Title As String
Dim FilterIndex As Integer
Dim Filename As Variant
' File filters
Filter = "All Files (*.*),*.*"
' Default Filter to *.*
FilterIndex = 3
' Set Dialog Caption
Title = "Select a File to Open"
' Select Start Drive & Path
ChDrive ("C")
ChDir ("C:\")
With Application
' Set File Name to selected File
Filename = .GetOpenFileName(Filter, FilterIndex, Title)
' Reset Start Drive/Path
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
 
At a glance it appears that the example you copied and pasted has ommitted substantial parts of the code that it references including the parts that actually call and open the dialog.

GetOpenFileName is the name of a Windows api function. Your example shows a procedure to gather some info (title, filter) that I assume will eventually be passed to the api function.

Stephen Lebans has an excellent website with considerable information/examples on using native Windows' dialog boxes. I don;t have the URL, but you should be able to find it easily enough. Try there for starters.

Cheers,
Bill
 
GetOpenFileName is a method of the Excel.Application object.
In access you may play with the FileDialog object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top