Create a desktop shortcut

elgringo56

Well-known Member
Joined
Apr 15, 2002
Messages
869
Can I, using VBA, create a desktop shortcut with icon that will allow the user to double click it open a given folder such as C:\xxxx\yyyy?
 
Hmmm, I wrote the procedure and tested it with Windows '00 and Excel XP. Just tested it on win '00 & xl '97, worked fine.

Are you sure Windows Scripting is enabled in your problem environment?

Try:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> test()
<SPAN style="color:#00007F">Dim</SPAN> a <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>, y <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, NwShrt <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
<SPAN style="color:#00007F">Set</SPAN> a = CreateObject("WScript.Shell")
a.popup "Test Scripting", 1, "Microsoft Excel"
<SPAN style="color:#00007F">Set</SPAN> a = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

No worries re: other thread, just thought the response was curious and I had a few critical points I wanted to share. Appreciate the follow up.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
On the windows 2000 computer, I am not sure of anything, It is my daughters, I file transfered my program to her and she ran it on hers and then told me it got a runtime error in the icon making code. other than that, I dont know a whole lot about it. Thanks, Nate. I will send your code to her and have her try and run it. That may be a whole lot more trouble than I care to get into now, thought. LOL.
 
Upvote 0
Quoting J-Walk from Power Programming..

Page 363, Another type of Message Box
Excel can access the Windows Scripting Host (WScript) and display...

...if you decide to use this alternate message box, be aware that system administrators often disable the Windows Scripting Host because of the threat of viruses. If the Windows Scripting Host is disabled, the code will generate an error.

So, maybe one of the administrators (One of your daughters... :wink: ) turned it off !! :LOL:
 
Upvote 0
Hi;

The below procedure places a short cut on desktop for the file F:\My Folders\Test.xls with a desired name,

Code:
Declare Function fCreateShellLink Lib "VB5STKIT.DLL" _
(ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, _
ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
'
Sub CreateShortCutFile()
LngResult = fCreateShellLink("..\..\Desktop", "MyShortCutFile", _
            "F:\My Folders\Test.xls", "")
End Sub


And, the below procedure places a shortcut on desktop for the folder F:\My Folders with a desired name,

Code:
Declare Function fCreateShellLink Lib "VB5STKIT.DLL" _
(ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, _
ByVal lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
'
Sub CreateShortCutFolder()
LngResult = fCreateShellLink("..\..\Desktop", "MyShortCutFolder", _
            "F:\My Folders", "")
End Sub


Note: Tested with Win2000/Office2000
 
Upvote 0
Hi Raider, not to take away from the Call...good one
but the VB5STKIT.DLL is the Visual Basic5 Setup Toolkit Library DLL and maybe only avial via VB5 ie. User does not/may not have this Dll.
 
Upvote 0
Hi Ivan;

I had to point out that in my answer, it's my fault. Thanks for your reply.
 
Upvote 0

Forum statistics

Threads
1,217,367
Messages
6,136,143
Members
449,994
Latest member
Rocky Mountain High

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top