Desktop Shortcut

M

Michael Rekas

Hi there

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

Thanks

Michael
 
M

Melanie Breden

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)
 
M

Michael Rekas

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
 
M

Melanie Breden

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)
 
Top