+ Reply to Thread
Results 1 to 4 of 4

Changing Display Icon

  1. #1
    ben
    Guest

    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. #2
    Steve Yandl
    Guest

    Re: 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" <&&&&bw_rgb@hotmail.com(remove this if mailing direct)> wrote in
    message news:BCB8B2FF-62A1-464A-8831-3A2276494522@microsoft.com...
    > 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. #3
    ben
    Guest

    Re: 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" <&&&&bw_rgb@hotmail.com(remove this if mailing direct)> wrote in
    > message news:BCB8B2FF-62A1-464A-8831-3A2276494522@microsoft.com...
    > > 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. #4
    Steve Yandl
    Guest

    Re: 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" <&&&&bw_rgb@hotmail.com(remove this if mailing direct)> wrote in
    message news:E9BF79F5-5344-4F7F-8036-A7B3964C74A1@microsoft.com...
    > 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" <&&&&bw_rgb@hotmail.com(remove this if mailing direct)> wrote in
    >> message news:BCB8B2FF-62A1-464A-8831-3A2276494522@microsoft.com...
    >> > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1