Open dialog box.

D

Daniel

1.Create a new module and paste the code from the MVPS website
2.Create a button on your form and select to create a click event (using
code).

they provided a Testit function which illustrates how to call it from
anywhere.

Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
MsgBox "You selected: " & ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function



the basic principle is

Dim strFilter As String
Dim lngFlags As Long
Dim Docpath, FileName,StartDir

strFilter = ahtAddFilterItem(strFilter, "Images Files",
"*.gif;*.jpeg;*.jpg;*.bmp;*.tif")
StartDir = "c:\"
Docpath = ahtCommonFileOpenSave(InitialDir:=StartDir,
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, DialogTitle:="Select
Document")
If Not Docpath = "" Then
FileName = Dir(Docpath)
End If

you define your filter (type of files you are looking for), then pass it to
the ahtCommonFileOpenSave (which open the dialog so your users can select a
file). I also used the StartDir to make it open already in a predetermined
directory to avaoid running around.

In y case DocPath will return the filePath and FileName
("c:\temp\test\excel01.xls")
 

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