Gruppe
Extern
Bereich
Wsh
Thema
DeskTop-Link zu einer Excel-Arbeitsmappe erstellen
Problem
Es soll ein DeskTop-Link zu einer in Zelle B1 genannten Excel-Arbeitsmappe erstellt werden. In der Entwicklungsumgebung muss ein Verweis zum Windows Scripting Host geschaltet sein.
Lösung
Geben Sie den nachfolgenden Code in ein Standardmodul ein und weisen Sie ihn einer Schaltfläche zu.
StandardModule: Modul1
Sub MakeDesktopShortcut()
Dim wsh As New IWshShell_Class
Dim SC As IWshShortcut_Class
Dim sPath As String, sFile As String
sPath = wsh.SpecialFolders.Item("Desktop")
sFile = Range("B1").Value
Set SC = wsh.CreateShortcut(sPath & "\test.lnk")
SC.TargetPath = sFile
SC.Hotkey = "CTRL+ALT+Z"
SC.Save
Set wsh = Nothing
End Sub