Running an application from its 'shortcut' not .exe using VBA ?

I

Isis

I am trying to call a program from a DB - I need to use the programs
shortcut as opposed to the actual .exe file as I want to start the program
in a specific folder - like the 'Start In' on a windows shortcut.

Can this be done or is there another way ?

Thanks
 
G

Guest

Create a shortcut as you normally would. Let's say the shortcut is called
MyDb. In your Access app's code, call the Shell function:
Shell "C:\MyFolder\MyDb.lnk"

The .lnk extension is for shortcuts.

HTH,
Barry
 
I

Isis

=?Utf-8?B?QmFycnkgR2lsYmVydA==?=
Create a shortcut as you normally would. Let's say the shortcut is
called MyDb. In your Access app's code, call the Shell function:
Shell "C:\MyFolder\MyDb.lnk"

The .lnk extension is for shortcuts.

HTH,
Barry


Thanks for that Barry but for some reason I am not able to get this to run
- I get an error when I click the button 'Run Time Error 5' 'Invalid
Procedure Call' - If I replace the shortcut link with the link to the exe
it all runs fime so I am assuming that I have got the syntax correct. Any
other ideas ?

Thanks
 
G

Guest

Hmm. I Think Shell might have a problem with shortcut files. Let's try the
ShellExecute API call instead.

Insert a new module and paste the following into it:

Public Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long


Then to use ShellExecute in your code:

ShellExecute 0, "OPEN", "c:\MyDb.lnk", "", "", 1

HTH,
Barry
 

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