Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 67
Default Changing Display Icon

Is there a way either through VBA or a Windows API call to change the display
icon of a shortcut located on the desktop?

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Changing Display Icon

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



"ben" (remove this if mailing direct) wrote in
message ...
Is there a way either through VBA or a Windows API call to change the
display
icon of a shortcut located on the desktop?

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?



  #3   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 67
Default Changing Display Icon

steve is it possible to use this method using a custom .ico file?

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"Steve Yandl" wrote:

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



"ben" (remove this if mailing direct) wrote in
message ...
Is there a way either through VBA or a Windows API call to change the
display
icon of a shortcut located on the desktop?

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Changing Display Icon

Yes, just point to the ico file, skip the comma and index number and don't
forget the quotes around the path.

Steve


"ben" (remove this if mailing direct) wrote in
message ...
steve is it possible to use this method using a custom .ico file?

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"Steve Yandl" wrote:

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



"ben" (remove this if mailing direct) wrote in
message ...
Is there a way either through VBA or a Windows API call to change the
display
icon of a shortcut located on the desktop?

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they
aren''t
expected to go into the code?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Icon Sets - Display icon in one cell depending upon value in anoth Nolene Excel Worksheet Functions 2 February 26th 10 05:43 AM
Changing the Excel Icon GLHEC-BLS Excel Discussion (Misc queries) 2 September 23rd 08 08:39 PM
can't display link as icon sgawler Excel Worksheet Functions 0 April 11th 08 04:56 PM
Changing File Icon jose luis Excel Discussion (Misc queries) 6 August 8th 05 07:54 PM
Changing icon krhyme[_5_] Excel Programming 2 August 2nd 05 05:19 PM


All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"