Desktop Shortcut

  • Thread starter Thread starter Michael Rekas
  • Start date Start date
M

Michael Rekas

Hi there

Is it possible to use VBA to generate desktop shortcut to a workbook?

Thanks

Michael
 
Hi Michael,

Michael said:
Is it possible to use VBA to generate desktop shortcut to a workbook?

set a reference on "Windows Scripting Host Object Model"-library

Sub DesktopShortcut()
Dim WSHShell As IWshShell
Set WSHShell = New IWshShell_Class

With WSHShell.CreateShortcut( _
WSHShell.SpecialFolders("Desktop") & "\" & ActiveWorkbook.Name & ".lnk")
.TargetPath = ActiveWorkbook.FullName
.Save
End With
End Sub

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 
Thank you for the replies. I like the "Windows Scripting Host Object
Model" code.

However is it possible to automatically set the reference to the
library?

Michael
 
Hallo Michael,

Michael said:
Thank you for the replies. I like the "Windows Scripting Host Object
Model" code.

However is it possible to automatically set the reference to the
library?


with the following defining no reference must be set:

Dim WSHShell As Object
Set WSHShell = CreateObject("WScript.Shell")

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top