Thank you
junior1544 for your suggestion. I tried something very similar but it won't let me add parameters to it.
Thanks to
dsi ![[thumbsup2] [thumbsup2] [thumbsup2]](/data/assets/smilies/thumbsup2.gif)
for the suggestion that steered me to this solution
![[wiggle] [wiggle] [wiggle]](/data/assets/smilies/wiggle.gif)
:
Option Explicit
Public Declare Function fCreateShellLink Lib "Vb5stkit.dll" (ByVal _
lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal _
lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long
Sub DoShortcut()
Dim lReturn As Long
Dim DestPath As String
Dim LinkArg As String
Dim ShortcutName As String
Dim AppPath As String
AppPath = "D:\Program Files\TSMN\"
DestPath = "C:\Program Files\Microsoft Office\Office\MSAccess.EXE"
LinkArg = " " & Chr(34) & AppPath & "TSMN.mdb" & Chr(34) & " /wrkgrp " & Chr(34) & AppPath & "TSMNSys.mdw" & Chr(34)
ShortcutName = "Shortcut to TSMN"
'Add shortcut to desktop
lReturn = fCreateShellLink("..\..\Desktop", ShortcutName, DestPath, LinkArg)
If lReturn = 0 Then
Beep
MsgBox "Error while creating Desktop shortcut for: " & ShortcutName & ".", vbCritical + vbOKOnly, "Create Error"
End If
'Add shortcut to Program Menu Group
lReturn = fCreateShellLink("", ShortcutName, DestPath, LinkArg)
If lReturn = 0 Then
Beep
MsgBox "Error while creating Program Menu Group shortcut for: " & ShortcutName & ".", vbCritical + vbOKOnly, "Create Error"
End If
'Add shortcut to Startup Group
'Note that on Windows NT, the shortcut will not actually appear in the Startup group until your next reboot.
lReturn = fCreateShellLink("\Startup", ShortcutName, DestPath, LinkArg)
If lReturn = 0 Then
Beep
MsgBox "Error while creating Startup Group shortcut for: " & ShortcutName & ".", vbCritical + vbOKOnly, "Create Error"
End If
End Sub
Call DoShortcut() from your code. It was important to set up the LinkArg variable using the Chr(34) in order to account for spaces within a folder name.