OVH Cloud OVH Cloud

Création d'un raccourci

1 réponse
Avatar
Paul
Bonjour =E0 tous,

J'ai quelques soucis avec mes fichier VBS.
En effet, il y a quelques temps j'ai obtenu le code ci-
dessous me permettant de cr=E9er un raccourci sur le bureau :


Const sFile =3D "\monfichier.vbs"

set WshShell =3D WScript.CreateObject("WScript.Shell")=20
strDesktop =3D WshShell.SpecialFolders("Desktop")=20
set oShellLink =3D WshShell.CreateShortcut(strDesktop=20
& "\monfichier.lnk")=20
oShellLink.TargetPath =3D PathFile & sFile=20
oShellLink.WindowStyle =3D 1
oShellLink.Hotkey =3D "CTRL+SHIFT+G"=20
oShellLink.Description =3D "Session monfichier"=20
oShellLink.IconLocation =3D PathFile & "\stopwtch.ani"
oShellLink.WorkingDirectory =3D PathFile
oShellLink.Save

'* Renvoie le chemin du fichier
Function PathFile()
Dim fso
Set fso =3D CreateObject("Scripting.FileSystemObject")
PathFile =3D fso.GetParentFolderName(WScript.ScriptFullName)
Set fso =3D Nothing
End Function


Hors aujourd'hui je souhaiterais remplacer le=20
fichier "\monfichier.vbs" par "\monfichier.xls", et je ne=20
sais pas quelles sont les lignes =E0 modifier pour que =E7a=20
fonctionne.

Merci d'avance.

Paulo

1 réponse

Avatar
Frédéric Sigonneau
Bonsoir,

Pour créer à l'aide d'un script vbs un raccourci sur le bureau vers un classeur
Excel, essaye ce genre de code (à copier dans le bloc notes et à enregistrer
dans un fichier avec extension .vbs) :

'===================== Const sFile = "ClasseurTestpdf.xls"
Const sPath = "D:fsdatas"

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, 20"
oShellLink.WorkingDirectory = sPath
oShellLink.Save
'======================
FS
---
Frédéric Sigonneau [MVP Excel - né un sans-culottide]
Gestions de temps, VBA pour Excel :
http://perso.wanadoo.fr/frederic.sigonneau
Si votre question sur Excel est urgente, évitez ma bal !


Bonjour à tous,

J'ai quelques soucis avec mes fichier VBS.
En effet, il y a quelques temps j'ai obtenu le code ci-
dessous me permettant de créer un raccourci sur le bureau :


Const sFile = "monfichier.vbs"

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop
& "monfichier.lnk")
oShellLink.TargetPath = PathFile & sFile
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+G"
oShellLink.Description = "Session monfichier"
oShellLink.IconLocation = PathFile & "stopwtch.ani"
oShellLink.WorkingDirectory = PathFile
oShellLink.Save

'* Renvoie le chemin du fichier
Function PathFile()
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
PathFile = fso.GetParentFolderName(WScript.ScriptFullName)
Set fso = Nothing
End Function


Hors aujourd'hui je souhaiterais remplacer le
fichier "monfichier.vbs" par "monfichier.xls", et je ne
sais pas quelles sont les lignes à modifier pour que ça
fonctionne.

Merci d'avance.

Paulo