Wednesday, May 23, 2012

This Blog is Dedicated to mgm (Manjunath Mg), as a follower of him, i thought to share info through this Blog.

Using VBA code to create a shortcut on users' desktops

'----------------------------------------------------------------
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
'----------------------------------------------------------------