Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Changer l'icône du raccourci par VBA

2 réponses
Avatar
Didier Novarin
Bonjour
Le talentueux Jacky m'a fourni cette procédure qui créé un raccourci sur le
bureau
Est-il possible par VBA de changer l'icône du raccourci par VBA ?
Je vous remercie
Didier


Sub CreerRaccourci()
Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\titre.lnk")
'**ici titre du raccourci**
oShellLink.TargetPath = "d:\chemin" '****Ici chemin complet de la
cible
oShellLink.WindowStyle = 1
oShellLink.Save
End Sub

2 réponses

Avatar
michdenis
Bonjour Didier,

Voici une procédure publiée sur ce forum par Frédéric Sigonneau :

Tu peux faire varier le "1" cette ligne de code
oShellLink.IconLocation = "shell32.dll, 1" de 1 à 20 environ.

Tu vas obtenir un des icônes de la liste,
un clic droit sur ton raccourci clavier sur le bureau / propriétés / changer l'icône ...

oShellLink.IconLocation = "shell32.dll, 1"

Tu peux spécifier le fichier DLL d'où tu veux extraire ton icône en utilisant une
ligne de code comme celle-ci : Insère chemin + Dll + numéro de l'icône
oShellLink.IconLocation = "c:WindowsSystem32shell32.dll, 3"
(cette façon de faire n'a pas été testé.


'---------------------------------
Sub CreationRaccourciSurLeBureau()

Const sFile = "Classeur1.xls"
Const sPath = "C:Atravail"

Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "MonClasseur.lnk")
oShellLink.TargetPath = sPath & sFile
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+G"
oShellLink.Description = "Session monfichier"
oShellLink.IconLocation = "shell32.dll, 1"
oShellLink.WorkingDirectory = sPath
oShellLink.Save
End Sub
'---------------------------------


Salutations!



"Didier Novarin" a écrit dans le message de news: %
Bonjour
Le talentueux Jacky m'a fourni cette procédure qui créé un raccourci sur le
bureau
Est-il possible par VBA de changer l'icône du raccourci par VBA ?
Je vous remercie
Didier


Sub CreerRaccourci()
Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "titre.lnk")
'**ici titre du raccourci**
oShellLink.TargetPath = "d:chemin" '****Ici chemin complet de la
cible
oShellLink.WindowStyle = 1
oShellLink.Save
End Sub
Avatar
Didier Novarin
Bonsoir Denis
Rien à dire remarquable !!!!
Merci BEAUCOUP
Très bonne soirée
Didier


"michdenis" a écrit dans le message de news:

Bonjour Didier,

Voici une procédure publiée sur ce forum par Frédéric Sigonneau :

Tu peux faire varier le "1" cette ligne de code
oShellLink.IconLocation = "shell32.dll, 1" de 1 à 20 environ.

Tu vas obtenir un des icônes de la liste,
un clic droit sur ton raccourci clavier sur le bureau / propriétés /
changer l'icône ...

oShellLink.IconLocation = "shell32.dll, 1"

Tu peux spécifier le fichier DLL d'où tu veux extraire ton icône en
utilisant une
ligne de code comme celle-ci : Insère chemin + Dll + numéro de l'icône
oShellLink.IconLocation = "c:WindowsSystem32shell32.dll, 3"
(cette façon de faire n'a pas été testé.


'---------------------------------
Sub CreationRaccourciSurLeBureau()

Const sFile = "Classeur1.xls"
Const sPath = "C:Atravail"

Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "MonClasseur.lnk")
oShellLink.TargetPath = sPath & sFile
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+G"
oShellLink.Description = "Session monfichier"
oShellLink.IconLocation = "shell32.dll, 1"
oShellLink.WorkingDirectory = sPath
oShellLink.Save
End Sub
'---------------------------------


Salutations!



"Didier Novarin" a écrit dans le message de
news: %
Bonjour
Le talentueux Jacky m'a fourni cette procédure qui créé un raccourci sur
le
bureau
Est-il possible par VBA de changer l'icône du raccourci par VBA ?
Je vous remercie
Didier


Sub CreerRaccourci()
Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "titre.lnk")
'**ici titre du raccourci**
oShellLink.TargetPath = "d:chemin" '****Ici chemin complet de la
cible
oShellLink.WindowStyle = 1
oShellLink.Save
End Sub