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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to allow user to select file 1

Status
Not open for further replies.

JoeSmoe55

Programmer
Aug 1, 2005
38
US
Hello,

I am using Access 2003 and I want to open a form that will allow the user to peruse through the filesystem and select a file, which control should I use? Is there a premade control given by windows? This would seem to be a common thing but I haven't a clue where to begin. Thank you kindly.

Joe
 
Public Function fPickFolder(str_StartDir) As String
'Declarations
Dim objshell As Object
Dim objFile As Object

'initializations
Set objshell = CreateObject("Shell.Application")
Set objFile = objshell.BrowseForFolder(0, "Select a Folder", 0, str_StartDir)

'if objfile exists then get the folder
If (Not objFile Is Nothing) Then
fPickFolder = objFile.Items.Item.Path
End If

'release variables
Set objshell = Nothing
Set objFile = Nothing

End Function

Randall Vollen
National City Bank Corp.
 
Oops you want a file, not a folder -- You'll have eto write a function/class to handle that.

Randall Vollen
National City Bank Corp.
 
You can use a drivelist box, and a directory listbox, but you are really recreating the wheel when you add all the programming to tie them together.

VB has an object to automate the Common File Open/Save box, but I don't know of a clean version of that control in VBA.

instead, I normally use code like this:


HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top