mike29091973
05-27-2013, 05:06 AM
Dear Sir,
I am usig below code for create shortcut in Excel VBA.
All is worling is I create short cut to program.
I need now create a foldershortcut ( a link to a folder) but it is not working.
It create .lnk shortcut but it doesn't open the foder to shortcut
Code in main sub is:
CreateShellShortcut "C:\FolderToShortcut, "", "Just a test", "C:\folder\MyShortCut.lnk")
and CreateShellShortCut function is:
Sub CreateShellShortcut(ByVal TargetName As String, _
ByVal TargetArguments As String, _
ByVal TargetDescription As String, _
ByVal ShortcutFileName As String)
Dim WSH As Object
Dim Shortcut As Object
Set WSH = CreateObject("WScript.Shell")
Set Shortcut = WSH.CreateShortcut(ShortcutFileName)
With Shortcut
.TargetPath = TargetName
.Arguments = TargetArguments
.Description = TargetDescription
.Save
End With
Set Shortcut = Nothing
Set WSH = Nothing
End Sub
I am usig below code for create shortcut in Excel VBA.
All is worling is I create short cut to program.
I need now create a foldershortcut ( a link to a folder) but it is not working.
It create .lnk shortcut but it doesn't open the foder to shortcut
Code in main sub is:
CreateShellShortcut "C:\FolderToShortcut, "", "Just a test", "C:\folder\MyShortCut.lnk")
and CreateShellShortCut function is:
Sub CreateShellShortcut(ByVal TargetName As String, _
ByVal TargetArguments As String, _
ByVal TargetDescription As String, _
ByVal ShortcutFileName As String)
Dim WSH As Object
Dim Shortcut As Object
Set WSH = CreateObject("WScript.Shell")
Set Shortcut = WSH.CreateShortcut(ShortcutFileName)
With Shortcut
.TargetPath = TargetName
.Arguments = TargetArguments
.Description = TargetDescription
.Save
End With
Set Shortcut = Nothing
Set WSH = Nothing
End Sub