I want to create a shortcut to a folder. Shortcut name is to be based on project name in textbox on a form called ProjectName. The shortcut location is to be based on name in a combo box on the same form called ComboEstimator. Code below does create the shortcut however it names the shortcut estimator + project name-shortcut. Not sure why it's adding estimator name to the shortcut name. And instead of creating the shortcut in folder with the same name of estimator it just creates the shortcut in P:\. I added "MsgBox Me.ComboEstimator.Column(1)" to the code and I can confirm that for the value returned there is a folder of the same name in P:\. I took this code from an excel workbook I have and tweaked it. Obviously I'm doing something wrong.
Code:
Private Sub Command247_Click()
Dim fdObj As Object
Dim objWSH As IWshRuntimeLibrary.WshShell
Dim objShortCut As IWshRuntimeLibrary.WshShortcut
Dim strPath As String
Dim strShortcutPath As String
Dim strShortcutName As String
Dim strShortcutToFile As String
strShortcutPath = "P:\" & Me.ComboEstimator.Column(1)
strShortcutName = (Me.ProjectName & "-" & "Shortcut.lnk")
strShortcutToFile = "P:\Brsm Projects\Access\" & Me.ProjectName
Set objWSH = New IWshRuntimeLibrary.WshShell
Set objShortCut = objWSH.CreateShortcut(strShortcutPath & strShortcutName)
Set fdObj = CreateObject("Scripting.FileSystemObject")
objShortCut.TargetPath = strShortcutToFile
objShortCut.Save
End Sub