Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Desktop Shortcut using VBA 2

Status
Not open for further replies.

PBAPaul

Programmer
Joined
Aug 3, 2002
Messages
140
Location
GB
I have an Excel program in which I wish to offer the user an option to create a desktop shortcut for the program.

How do I do it from within the Excel program using VBA?

My grateful thanks to anybody who can help.
 
You may consider to use the Microsoft Scripting Runtime:
Set S = CreateObject("WScript.Shell")
DesktopPath = S.SpecialFolders("AllUsersDesktop") 'or "Desktop"
Set MyShortcut = S.CreateShortcut(DesktopPath & "\Name of link.lnk")
MyShortcut.TargetPath = "\path\to\target.ext"
MyShortcut.Arguments = "Command line arguments"
MyShortcut.WorkingDirectory = "\path\to\startdir"
MyShortcut.Save

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks PH - works perfectly!
 
PHV -

This is very cool! Thanks!

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top