I need to create shortcuts for selected files within selected folders. On several sites (including stackoverflow) I found the following code:
Private Sub MakeShortcut(ByVal File As String, ByVal ShortcutFolder As String, ByVal Name As String, ByVal WorkDirectory As String)
Dim WshShell As Object = CreateObject("WScript.Shell")
Dim NewShortcut As Object = WshShell.CreateShortcut(ShortcutFolder & "\" & Name & ".lnk")
NewShortcut.TargetPath = File
NewShortcut.WindowStyle = 1
NewShortcut.IconLocation = File & ",0"
NewShortcut.WorkingDirectory = WorkDirectory
NewShortcut.Save()
End Function
Of course I added a reference to Interop.IWshRuntimeLibrary.dll
to my Project and "Imports IWshRuntimeLibrary" within the 'general' section of the form.
Nevertheless I do get the message "Option Strict dissallows late binding" for all appearances of "whshell." and "Newshortcut."
Why am I getting this error and how can I fix it?