Create Shortcut for Notepad on Desktop (VBA)
The following code creates a shortcut for notepad on Desktop. You can modify the code for creating shortcuts to other applications as well.
Sub CreateNotepadShortcut() Dim objWSH As Object Dim objShortCut As Object Dim strPath As String '----If Early Binding set a referece to Windows Script Host Object Module-- 'Dim objWSH As New IWshRuntimeLibrary.IWshShell_Class 'Dim objShortCut As IWshRuntimeLibrary.IWshShortcut_Class '========================================================================== '----Late Binding---------------------------------------------------------- Set objWSH = CreateObject("WScript.Shell") '========================================================================== strPath = objWSH.SpecialFolders("Desktop") & "\" & "Notepad.lnk" Set objShortCut = objWSH.CreateShortcut(strPath) With objShortCut .TargetPath = Environ("WINDIR") & "\" & "notepad.exe" .Description = "Shortcut to Notepad" .IconLocation = "C:\Windows\System\Shell32.dll,5" .RelativePath = "C:\Temp" .WorkingDirectory = "C:\" .Hotkey = "Ctrl+Alt+C" .Save End With Set objWSH = Nothing Set objShortCut = Nothing End Sub
»
- Vishesh's blog
- Login or register to post comments
- 15147 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago