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.
I need to run a shortcut call name.lnk file? Is this possiable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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
ASKER
Yes, that worked, I had a little trouble finding and implamenting the function, but I found some code off the internet. Regards
thatdbme