by PaPPy (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 11th December 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code allows you to create a shortcut on the desktop, when you click a command button. Can be put on a timer or on load of a form. Make
API Declarations
'
' NOTE: There must be a reference to "Windows Script Host Object Model" for this macro to work & have a command1 button.
' The default ICON is assigned.
' *************************************************************
Public Sub Command1_Click()
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 = Form1.Caption ' This is what I've selected at the title of the ShortCut
lsPath = App.Path & "\" & App.EXEName & ".exe" ' 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
No comments have been posted about This code allows you to create a shortcut on the desktop, when you click a command button. Can be p. Why not be the first to post a comment about This code allows you to create a shortcut on the desktop, when you click a command button. Can be p.