• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

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.
0
rquinn98
Asked:
rquinn98
1 Solution
 
keenezCommented:
Try shellExecute instead of shell.

Cheers,

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

thatdbme
0
 
winner21Commented:
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
winner21Commented:
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
0
 
rquinn98Author Commented:
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
0
 
rquinn98Author Commented:
Yes, that worked, I had a little trouble finding and implamenting the function, but I found some code off the internet.  Regards
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now