Dialog box that lets the user select the location of a file and st

B

BZeyger

I am looking for the code that I can enter on a command button to bring up a
windows dialog box. This box is supposed have the user link to a location of
a .pdf file. The location would be stored in a data field named txtlocation
which will connect to a table. I plan to have this datafield as a hyperlink.
How would this be done?
 
B

BZeyger

Thank you for this website, but I found it very confusing. I could not get it
to work. Is there an example of this in action?
 
D

Douglas J. Steele

You need to copy everything in the shaded area (between Code Start and Code
End) into a new module (not a class module nor a module associated with a
form or report). When you save the module, make sure you don't name it the
same as any existing functions. A name like "mdlFileDialog" should be save.

Once you've done, that, you need to use code like the four lines at the top
of the page:

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

You'd change the line

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")

to

strFilter = ahtAddFilterItem(strFilter, "Acrobat Files (*.PDF)", "*.PDF")

to have it work with PDF files.
 
B

BZeyger

Ok....This is great. The dialog box is working and displaying what I want.
However, how do I insert the location I navigated to in the txtLocation field
of my selected record


Thanks
 
B

BZeyger

I figured it out, I entered:
Me.txtLocation = strInputFileName


Thanks for all of your help
 
J

jo

Hi Douglas I noticed this thread on the forum and I needed something like
this and it works great and the extra piece to paste the path in the field.
BUT I would like more options on the type of files to open power point,
word,excel etc.. is this possible?
jo
 
D

Douglas J. Steele

Just set your filter appropriately.

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strFilter = ahtAddFilterItem(strFilter, "PowerPoint Files (*.PPT)", "*.PPT")
strFilter = ahtAddFilterItem(strFilter, "Word Files (*.DOC)", "*.DOC")
 
J

jo

Hi Douglas thanks for your response, I was looking on different forums and
noticed someone had put "Any Files" for a simular code so I tried it and it
works.

strFilter = ahtAddFilterItem(strFilter, "Any files (*.*)", "*.*")

thanks Jo
 

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