ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a shortcut (https://www.excelbanter.com/excel-programming/301703-running-shortcut.html)

newbie

Running a shortcut
 
how do I run a .lnk file from VBA? I have tried the shell command but with no success. Any help appreciated.

Jim Rech

Running a shortcut
 
Something like this may work for you:

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 a()
ShellExecute 0, "open", "C:\MyLink.lnk", "", "c:\", 1
End Sub


--
Jim Rech
Excel MVP
"Newbie" wrote in message
...
| how do I run a .lnk file from VBA? I have tried the shell command but
with no success. Any help appreciated.




All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com