Creating a Shortcut on the Desktop:   Return to List

' There must be a reference to "Windows Script Host Object Model" for this macro to work.
' The default ICON is assigned.

Public Sub Main()
    Dim objShell As IWshShell_Class
    Dim objShortcut As IWshShortcut_Class
    Dim FolderItem As Variant
    Dim lsPath As String
    Dim lsShortCut As String
    Dim lsURL As String
    Dim lsConfigFileName As String
    Dim nType As Variant
    
    Set objShell = New IWshShell_Class
    
    lsShortCut = ActiveWindow.Caption' This is what I've selected at the title of the ShortCut
    lsPath = Application.Path & "\" & Application.Name' Setting Microsoft Word -- or anything, really, as executable
    
    For Each FolderItem In objShell.SpecialFolders
        If Mid(FolderItem, Len(FolderItem) - 6, 7) = "Desktop" And _
            InStr(1, FolderItem, "All Users") = 0 And _
            InStr(1, UCase(FolderItem), "ADMINISTRATOR") = 0 Then
            Set objShortcut = objShell.CreateShortcut(FolderItem & "\" & lsShortCut & ".lnk")
            objShortcut.TargetPath = lsPath
            objShortcut.Arguments = lsURL & " " & lsConfigFileName & " " & CStr(nType)
            objShortcut.Save
        End If
    Next
End Sub



Note to Webmaster