Email form with browse for file

  • Thread starter Hugh self taught
  • Start date
H

Hugh self taught

Hi to all the clever people,

I have a form that has the necessary code / programming to send messages via
my outlook client. It also has a text box for a path & filename to send as an
attachment. However what I'd like to do is incorporate the windows "standard
Windows File Open/Save dialog box" api if possible in order to populate that
text box.

I've had a look at the api links on the mvps.org & at present they just
confuse me even more. I just can't seem to grasp what to use & what goes
where on this issue. So I really need some idiot guidance & assistance with
this if anyone can be so kind.

Thanks
Hugh
 
J

Jack Leach

These APIs are definately pretty complicated when trying to figure them out
and are initially setting them up. Luckily once you have that done its
pretty simple to use. The only one you should need is this:

http://www.mvps.org/access/api/api0001.htm

Take all the code in the semi-greyed out box and copy and paste into a
standard module (not a class module and not a form/report's module). Compile
& Save (hopefully you don't run into issues compiling...). The only thing I
change in this code is the filter that's added. Scroll down in this module
and find the function GetOpenFile. Towards the end of the function you'll see
this:

' Define the filter string and allocate space in the "c"
' string Duplicate this line with changes as necessary for
' more file templates.
strFilter = ahtAddFilterItem(strFilter, _
"Access (*.mdb)", "*.MDB;*.MDA")


Change the strFilter line to:

strFilter = ahtAddFilterItem(strFilter, _
"All Files (*.*)", "*.*")


Now all you should need is to use the GetOpenFile function to set the value
of your textbox:

Me.TextBoxName = GetOpenFile

If you want a particular directory to open, include it as the first
argument, and the second argument will give your file dialog a title of your
choosing.

Me.TextBoxName = GetOpenFile("C:\ThisDir\", "Pick your file...")



hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
H

Hugh self taught

Thanks Jack,

Somehow my grey matter seems to work better at 2:00am so I've finally got
this all working including the sending attachments via email etc just as I
was hoping to get it.

Cheers
Hugh
 

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