PDA

View Full Version : Shortcut



kellyhell
02-10-2012, 03:28 AM
Does anyone have some code that will automatically create a shortcut to the sheet they open.

The shortcut will be placed on the desktop and will only be created the first time they open the sheet.

TIA

Bob Phillips
02-10-2012, 05:14 AM
'----------------------------------------------------------------
Sub CreateShortCut()
'----------------------------------------------------------------
Dim oWSH As Object
Dim oShortcut As Object
Dim sPathDeskTop As String

Set oWSH = CreateObject("WScript.Shell")
sPathDeskTop = oWSH.SpecialFolders("Desktop")

Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
ActiveWorkbook.Name & ".lnk")
With oShortcut
.TargetPath = ActiveWorkbook.FullName
.Save
End With
Set oWSH = Nothing

End Sub

kellyhell
02-10-2012, 05:59 AM
Brilliant

Works a treat.

thank you for your time