Start an Application from a Form

Pharmer

New member
Local time
Yesterday, 19:00
Joined
Jul 2, 2007
Messages
3
My program consists of a single table of numerous suppliers and fields containing information on each one. One field is setup as a hypertext field containing the file address of a powerpoint presentation for each supplier while another field contains the file address of an Acrobat file for each supplier. I would like to program two Command Buttons on a form which, when clicked, will open up the specific Acrobat or Powerpoint file for the vendor chosen from a combo box. I'm sure this is really not difficult to do but I am a total amateur in Access and visual basic. If the combo box is named combo5 and the field name in the table is SalesLiterature or Presentation, exactly how do I modify the visual basic event procedure to accomplish this? Any help would be greatly appreciated!
 
Look up the Shell function you can run an exe with it.
 
Thanks KeithG. I tried to follow the advise in other posts using the shell command but I guess I just don't understand how to add the field name to the expression so that the file from the combo box is the one that is opened. How do I format the stAppName = statement? As I said, I really am a beginner. Also, is it necessary to state the path to the application in the code or would the individual computer know where Acrobat or Powerpoint is located on that particular machine?
 
Last edited:
bump
Can anyone help? I've still been unable to solve this issue.
 
I've never used the datatype you mention, I would store the document path in text fields, then use the ShellExecute API to execute it.

That sounds terribly hard, but really isn't. Dev Ashish has made a terrific wrapper function for it http://www.mvps.org/access/api/api0018.htm which you just have to copy to a standard module (in VBE - Insert | Module), name it for instance basHandleFile.

Then, your "behind the pdf button code" might look something like this:

dim retval as integer
if me!cboNameOfYourCombo.value = "PDF" then
Call fhandlefile(me!txtPathOfPDF.value, WIN_MAX)
end if

Though I don't use it, there's also the Followhyperlink method of the application object, you should be able to do something like

application.followhyperlink me!txtPathOfPDF.value

too. Neither of these two methods need the path of the application, which Shell needs, so I think they are easier to work with. I don't know if it works with hyperlink datatype, but try it out, and see.
 
May I ask more on this topic, I have done around 4 hours to search with the below question, but nothing I can find....please help...:(

I can run the application by using the below VBA code,

PowerPoint = Shell(C:\Program Files\Microsoft Office\OFFICE11\POWERPNT.EXE", 1)

But, how can we open the file (extension is .ppt), let's say C:\Training\Training.ppt???

I would like to open the PowerPoint File by clicking a link in Access Form.

Please help.
 
May I ask, when I use the Shell () Function, do I need to enable some library in Tools > References ?
 
Bump

If you still didn't get it to work, try this:

Call Shell("""C:\Program Files\Microsoft Office\OFFICE11\POWERPNT.EXE"" C:\Training\Training.ppt", 1)

That worked for me.
I came here looking for an answer and ended up figuring it out on my own.
You shouldn't need to mess with the references unless one is missing for some reason.

Cheers
 
Last edited:

Users who are viewing this thread

Back
Top Bottom