Create shortcuts to files on any location under program control, such as desktop, startup, etc. usi
Create shortcuts to files on any location under program control, such as desktop, startup, etc. using the Shell object
API Declarations
Public Enum SHORTCUT_LOCATIONS
DesktopAll = 0
StartMenuAll = 1
ProgramsAll = 2
StartupAll = 3
DesktopNow = 4
ApplicationDataNow = 5
PrintHoodNow = 6
TemplatesNow = 7
WinFonts = 8
NetHoodNow = 9
DesktopNowAlt = 10
StartMenuNow = 11
SendToNow = 12
RecentNow = 13
StartUpNowAlt = 14
FavouritesNow = 15
MyDocsNow = 16
ProgramsNow = 17
End Enum
Rate Create shortcuts to files on any location under program control, such as desktop, startup, etc. usi
(2(2 Vote))
'stFileNameRef stores the name and path of the file to create the shortcut from
'stLocation is for where the shortcut will be created
'stLinkName is for the caption of the shortcut link created
Sub Create_Shortcuts(stFileNameRef As String, stLocation As SHORTCUT_LOCATIONS, stLinkName as String)
Dim objWshShell As Object
Dim objShellLink As Object
Dim strAutoStart
Set objWshShell = CreateObject("WScript.Shell")
strAutoStart = objWshShell.SpecialFolders(stLocation)
If Dir(stFileNameRef) = "" Then Exit Sub
Set objShellLink = objWshShell.CreateShortcut(strAutoStart & "\" & _ stLinkName & ".lnk")
With objShellLink
.TargetPath = stFileNameRef
.WindowStyle = 1
.Description = stLinkName
.Save
End With
Set objShellLink = Nothing
Set objWshShell = Nothing
End Sub
Create shortcuts to files on any location under program control, such as desktop, startup, etc. usi Comments
No comments yet — be the first to post one!
Post a Comment