Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Icon of a Shortcut with VBA?
Hi To All,
Is it possible to change the icon of a desktop shortcut using VBA? And also using VBA, can you search for and identify the shortcut to change using it's target path? Any help appreciated. Walt |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Icon of a Shortcut with VBA?
Hi Walt;
You can recreate it by changing the name of the file icon; one example: With CreateObject("WScript.Shell") With .CreateShortcut(.SpecialFolders("Desktop") & "\Gpao.lnk") .TargetPath = ThisWorkbook.Path & "\Gpao.vbe" .WindowStyle = 1 .Hotkey = "CTRL+SHIFT+G" .IconLocation = ThisWorkbook.Path & "\Gpao.ico, 0" .Description = "Session GPAO" .WorkingDirectory = ThisWorkbook.Path .Save End With End With MP "Walt Weber" a écrit dans le message de ... Hi To All, Is it possible to change the icon of a desktop shortcut using VBA? And also using VBA, can you search for and identify the shortcut to change using it's target path? Any help appreciated. Walt |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Icon of a Shortcut with VBA?
Sub MakeShortcut()
With CreateObject("WScript.Shell") With _ .CreateShortcut(.SpecialFolders("Desktop") & "\MRS.lnk") .TargetPath = ThisWorkbook.Path & "\" & ThisWorkbook.Name .WindowStyle = 1 .Hotkey = "" .IconLocation = ThisWorkbook.Path & "\Icon.ico, 0" .Description = "by: Spreadsheet Design & Automation Co." .WorkingDirectory = ThisWorkbook.Path .Save End With End With End Sub -----Original Message----- Hi Walt; You can recreate it by changing the name of the file icon; one example: With CreateObject("WScript.Shell") With .CreateShortcut(.SpecialFolders("Desktop") & "\Gpao.lnk") .TargetPath = ThisWorkbook.Path & "\Gpao.vbe" .WindowStyle = 1 .Hotkey = "CTRL+SHIFT+G" .IconLocation = ThisWorkbook.Path & "\Gpao.ico, 0" .Description = "Session GPAO" .WorkingDirectory = ThisWorkbook.Path .Save End With End With MP "Walt Weber" a écrit dans le message de ... Hi To All, Is it possible to change the icon of a desktop shortcut using VBA? And also using VBA, can you search for and identify the shortcut to change using it's target path? Any help appreciated. Walt . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Icon of a Shortcut with VBA?
Sub MakeShortcut()
With CreateObject("WScript.Shell") With _ .CreateShortcut(.SpecialFolders("Desktop") & "\MRS.lnk") .TargetPath = ThisWorkbook.Path & "\" & ThisWorkbook.Name .WindowStyle = 1 .Hotkey = "" .IconLocation = ThisWorkbook.Path & "\Icon.ico, 0" .Description = "by: Spreadsheet Design & Automation Co." .WorkingDirectory = ThisWorkbook.Path .Save End With End With End Sub -----Original Message----- Hi Walt; You can recreate it by changing the name of the file icon; one example: With CreateObject("WScript.Shell") With .CreateShortcut(.SpecialFolders("Desktop") & "\Gpao.lnk") .TargetPath = ThisWorkbook.Path & "\Gpao.vbe" .WindowStyle = 1 .Hotkey = "CTRL+SHIFT+G" .IconLocation = ThisWorkbook.Path & "\Gpao.ico, 0" .Description = "Session GPAO" .WorkingDirectory = ThisWorkbook.Path .Save End With End With MP "Walt Weber" a écrit dans le message de ... Hi To All, Is it possible to change the icon of a desktop shortcut using VBA? And also using VBA, can you search for and identify the shortcut to change using it's target path? Any help appreciated. Walt . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Icon of a Shortcut with VBA?
Sub MakeShortcut()
With CreateObject("WScript.Shell") With _ .CreateShortcut(.SpecialFolders("Desktop") & "\MRS.lnk") .TargetPath = ThisWorkbook.Path & "\" & ThisWorkbook.Name .WindowStyle = 1 .Hotkey = "" .IconLocation = ThisWorkbook.Path & "\Icon.ico, 0" .Description = "by: Spreadsheet Design & Automation Co." .WorkingDirectory = ThisWorkbook.Path .Save End With End With End Sub -----Original Message----- Hi Walt; You can recreate it by changing the name of the file icon; one example: With CreateObject("WScript.Shell") With .CreateShortcut(.SpecialFolders("Desktop") & "\Gpao.lnk") .TargetPath = ThisWorkbook.Path & "\Gpao.vbe" .WindowStyle = 1 .Hotkey = "CTRL+SHIFT+G" .IconLocation = ThisWorkbook.Path & "\Gpao.ico, 0" .Description = "Session GPAO" .WorkingDirectory = ThisWorkbook.Path .Save End With End With MP "Walt Weber" a écrit dans le message de ... Hi To All, Is it possible to change the icon of a desktop shortcut using VBA? And also using VBA, can you search for and identify the shortcut to change using it's target path? Any help appreciated. Walt . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Change Icon of a Shortcut with VBA?
Hi Michel,
That last transmisssion shouldn't have been sent. Please read this one. Thank you - your response works! I don't quite understand why or how. I've modified it to: Sub MakeShortcut() With CreateObject("WScript.Shell") With _ .CreateShortcut(.SpecialFolders("Desktop") & "\MRS.lnk") .TargetPath = ThisWorkbook.Path & "\" & ThisWorkbook.Name .WindowStyle = 1 .Hotkey = "" .IconLocation = ThisWorkbook.Path & "\Icon.ico, 0" .Description = "by: Walt" .WorkingDirectory = ThisWorkbook.Path .Save End With End With End Sub Why doesn't it crash when there's an existing .ico file with that name (You can run this routine multiple times with no conflict)? Furthermore, your response did not address whether it's possible or practical to change or replace all shortcut icons pointed to the same file. Is it? You're the master in this area - not me. Best Regards, Walt -----Original Message----- Hi Walt; You can recreate it by changing the name of the file icon; one example: With CreateObject("WScript.Shell") With .CreateShortcut(.SpecialFolders("Desktop") & "\Gpao.lnk") .TargetPath = ThisWorkbook.Path & "\Gpao.vbe" .WindowStyle = 1 .Hotkey = "CTRL+SHIFT+G" .IconLocation = ThisWorkbook.Path & "\Gpao.ico, 0" .Description = "Session GPAO" .WorkingDirectory = ThisWorkbook.Path .Save End With End With MP "Walt Weber" a écrit dans le message de ... Hi To All, Is it possible to change the icon of a desktop shortcut using VBA? And also using VBA, can you search for and identify the shortcut to change using it's target path? Any help appreciated. Walt . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a shortcut command or quick access icon for subscript? | Excel Discussion (Misc queries) | |||
shortcut icon properties | Excel Discussion (Misc queries) | |||
Is there a shortcut icon for deleting row/columns in the tool bar | Excel Discussion (Misc queries) | |||
There should be a shortcut icon for "wrap text" | Excel Discussion (Misc queries) | |||
Running a macro from a desktop icon shortcut | Excel Programming |