Thanks do
![[thumbsup2] [thumbsup2] [thumbsup2]](/data/assets/smilies/thumbsup2.gif)
dsi for the suggestion above. I needed to be able to include the parameter to use an MS-Access workgroup that is being used by the database.
![[wiggle] [wiggle] [wiggle]](/data/assets/smilies/wiggle.gif)
I played with this for quite some time the arrive at this solution:
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.