Link to home
Start Free TrialLog in
Avatar of rquinn98
rquinn98

asked on

How can I launch or run an Shortcut (lnk) thru VB?

The shell command only seems to run .exe files?
I need to run a shortcut call name.lnk file? Is this possiable.
ASKER CERTIFIED SOLUTION
Avatar of keenez
keenez

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thatdbme
thatdbme

I am not familiar with shellExecute.  I looked it up in MSDN but got no results, please explain keenez.

thatdbme
the following is the code for your reference:

Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

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

Sub RunYourProgram()
  Dim RetVal As Long
  On Error Resume Next
  RetVal = ShellExecute(0, "open", "<full path to program>", "<arguments>", "<run in folder>", SW_SHOWMAXIMIZED)
End Sub


Good luck.
ShellExecute to start any program - including a short cut (.lnk) file - from inside VBA. This can be used in any of your VBA enabled programs - typically any of the applications in the Windows Office series
Avatar of rquinn98

ASKER

Yes, that worked !  Thank you.  It took a while for me to add the code but I was able to download it from the internet somewhere.   Thanks Again
Yes, that worked, I had a little trouble finding and implamenting the function, but I found some code off the internet.  Regards