G
Guest
Is there a way either through VBA or a Windows API call to change the display
icon of a shortcut located on the desktop?
icon of a shortcut located on the desktop?
Steve Yandl said:ben,
It can be done with the "WScript.Shell" object.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Sub ChangeLnkIcon()
' Changes icon for desktop shortcut named TestA to the 21st icon in shell32
Set wsh = CreateObject("WScript.Shell")
strDesktop = wsh.SpecialFolders("Desktop")
Set objLink = wsh.CreateShortcut(strDesktop & "\TestA.lnk")
With objLink
.IconLocation = "%SystemRoot%\system32\SHELL32.dll, 20"
.Save
End With
End Sub
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Even though you would not see the lnk extension on the shortcut name (TestA
in my example),you need to include the LNK extension. If no shortcut named
TestA were found on the desktop, a new shortcut with that name (and no
Target) would be created. The .Save is required to create a new shortcut or
to save edits, otherwise CreateShortcut simply makes the various properties
like IconLocation available for reading.
Steve Yandl