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!

Get the Path of a file to be imported 2

Status
Not open for further replies.

cyork

MIS
Apr 4, 2001
34
CA
I have a function that populates a table from an excel spreadsheet. I want to be able to prompt the user to indicate the location of the file (open a browse directory window) to be imported.

Thanks,

Chris
 
You need to look up Windows API calls. I have done it before, but it is a bit lengthy to describe. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
What I meant to say was... You can use a Windows Common Dialog Box call to get Windows Standard Directory window, and when they click ok (or open, can't remember which) it will return the path and file name. The following code is from Access 97 Developer's Handbook by Litwin, Getz and Gilbert (SYBEX) and makes the function call. Hopefully you can get enough information out of it to use, otherwise, I suggest buying the book.
Code:
Sub TestGetFileName()
    ' From Access 97 Developer's Handbook
    ' by Litwin, Getz, and Gilbert (Sybex)
    ' Copyright 1997.  All rights reserved.
    
    Dim gfni As adh_accOfficeGetFileNameInfo
    With gfni
        .hwndOwner = Application.hWndAccessApp
        .strAppName = "Delete Extra HTML"
        .strDlgTitle = "Select an HTML File"
        .strOpenTitle = "Select"
        .strFile = ""
        .strInitialDir = "C:\Windows\Temporary Internet Files\Cache1"
        .strFilter = "HTML (*.html;*.htm)|HTM Files (*.htm)|HTX Files (*.htx)|All Files (*.*)"
        .lngFilterIndex = 1
        .lngView = adhcGfniViewList
        .lngFlags = adhcGfniNoChangeDir Or adhcGfniInitializeView
    End With
    If adhOfficeGetFileName(gfni, True) = adhcAccErrSuccess Then
        MsgBox "You chose: " & Trim(gfni.strFile), vbOKOnly, "Test Get File Name"
    End If
End Sub
Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top