OVH Cloud OVH Cloud

creer un raccourci dans un dossier

6 réponses
Avatar
MK
Bonjour

Je voudrais créer un nouveau dossier dans c:TOTO et ensuite creer un
raccourci du nouveau dossier sur le bureau.
Sub Creer()
No = Range("A1").Value
Da = Range("A2").Value
MkDir "C:\TOTO\" & No & "(" & Da & ")"
' Je suis rendu là
End Sub

Merci beaucoup de votre aide

MK

6 réponses

Avatar
Sonic
Bonjour.

Sub Creer()
Dim no As String
Dim da As String
Dim chemin As String
Dim nom As String
Dim Commentaire As String

no = Feuil1.Range("A1").Value
da = Feuil1.Range("A2").Value
chemin = "C:TOTO" & no & "(" & da & ")"
nom = no & "(" & da & ")" & ".Lnk"
Commentaire = chemin

MkDir chemin
' Je suis rendu là
RaccourciSurBureau nom, chemin, , , , Commentaire
End Sub

Function RaccourciSurBureau(sNom As String, sChemin As String, _
Optional sParam As String, Optional sRepertoireDeTravail As String, _
Optional sIcon As String, Optional sComment As String)
Dim OBJ As Object, oShellLink As Object
Set OBJ = CreateObject("wscript.shell")
Set oShellLink = OBJ.CreateShortcut(sNom)
Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & ""
& sNom)


With oShellLink
.TargetPath = sChemin
.Arguments = sParam
.WorkingDirectory = sRepertoireDeTravail
If sIcon = "" Then sIcon = sChemin
.IconLocation = sIcon
.Description = sComment
.Save
End With
End Function



"MK" wrote in message
news:
Bonjour

Je voudrais créer un nouveau dossier dans c:TOTO et ensuite creer un
raccourci du nouveau dossier sur le bureau.
Sub Creer()
No = Range("A1").Value
Da = Range("A2").Value
MkDir "C:TOTO" & No & "(" & Da & ")"
' Je suis rendu là
End Sub

Merci beaucoup de votre aide

MK



Avatar
MK
Merci,mais j'ai un bug avec cette ligne.

Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & ""
& sNom)



Bonjour.

Sub Creer()
Dim no As String
Dim da As String
Dim chemin As String
Dim nom As String
Dim Commentaire As String

no = Feuil1.Range("A1").Value
da = Feuil1.Range("A2").Value
chemin = "C:TOTO" & no & "(" & da & ")"
nom = no & "(" & da & ")" & ".Lnk"
Commentaire = chemin

MkDir chemin
' Je suis rendu là
RaccourciSurBureau nom, chemin, , , , Commentaire
End Sub

Function RaccourciSurBureau(sNom As String, sChemin As String, _
Optional sParam As String, Optional sRepertoireDeTravail As String, _
Optional sIcon As String, Optional sComment As String)
Dim OBJ As Object, oShellLink As Object
Set OBJ = CreateObject("wscript.shell")
Set oShellLink = OBJ.CreateShortcut(sNom)
Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & ""
& sNom)


With oShellLink
.TargetPath = sChemin
.Arguments = sParam
.WorkingDirectory = sRepertoireDeTravail
If sIcon = "" Then sIcon = sChemin
.IconLocation = sIcon
.Description = sComment
.Save
End With
End Function



"MK" wrote in message
news:
Bonjour

Je voudrais créer un nouveau dossier dans c:TOTO et ensuite creer un
raccourci du nouveau dossier sur le bureau.
Sub Creer()
No = Range("A1").Value
Da = Range("A2").Value
MkDir "C:TOTO" & No & "(" & Da & ")"
' Je suis rendu là
End Sub

Merci beaucoup de votre aide

MK








Avatar
MK
Désolé Sonic j'ai fait une erreur dans la copie. Ça fonctionne à merveille.

Sur la même ligne dans VBA.
Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & "" &
sNom)

Merci beaucoup

MK


Merci,mais j'ai un bug avec cette ligne.

Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & ""
& sNom)



Bonjour.

Sub Creer()
Dim no As String
Dim da As String
Dim chemin As String
Dim nom As String
Dim Commentaire As String

no = Feuil1.Range("A1").Value
da = Feuil1.Range("A2").Value
chemin = "C:TOTO" & no & "(" & da & ")"
nom = no & "(" & da & ")" & ".Lnk"
Commentaire = chemin

MkDir chemin
' Je suis rendu là
RaccourciSurBureau nom, chemin, , , , Commentaire
End Sub

Function RaccourciSurBureau(sNom As String, sChemin As String, _
Optional sParam As String, Optional sRepertoireDeTravail As String, _
Optional sIcon As String, Optional sComment As String)
Dim OBJ As Object, oShellLink As Object
Set OBJ = CreateObject("wscript.shell")
Set oShellLink = OBJ.CreateShortcut(sNom)
Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & ""
& sNom)


With oShellLink
.TargetPath = sChemin
.Arguments = sParam
.WorkingDirectory = sRepertoireDeTravail
If sIcon = "" Then sIcon = sChemin
.IconLocation = sIcon
.Description = sComment
.Save
End With
End Function



"MK" wrote in message
news:
Bonjour

Je voudrais créer un nouveau dossier dans c:TOTO et ensuite creer un
raccourci du nouveau dossier sur le bureau.
Sub Creer()
No = Range("A1").Value
Da = Range("A2").Value
MkDir "C:TOTO" & No & "(" & Da & ")"
' Je suis rendu là
End Sub

Merci beaucoup de votre aide

MK










Avatar
MK
Bonjour, ça fonctionne très bien mais si je veux envoyer le raccourci dans
un autre folder.

Dim dos As String

dos = "C:Raccourci" & no ' ou autre chemin

Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders(dos) & "" & sNom)
'mais ça fonctionne pas

Merci beaucoup de ton aide MK
Avatar
Sonic
Sub Creer()
Dim no As String
Dim da As String
Dim chemin As String
Dim nom As String
Dim Commentaire As String
Dim CheminDuLien As String


no = Feuil1.Range("A1").Value
da = Feuil1.Range("A2").Value
chemin = "C:TOTO" & no & "(" & da & ")"
nom = no & "(" & da & ")" & ".Lnk"
Commentaire = chemin

MkDir chemin
' Je suis rendu là
RaccourciSurBureau nom, chemin, , , , Commentaire

CheminDuLien = "C:" & nom

Raccourci CheminDuLien, chemin, , , , Commentaire

End Sub

Function RaccourciSurBureau(sNom As String, sChemin As String, _
Optional sParam As String, Optional sRepertoireDeTravail As String, _
Optional sIcon As String, Optional sComment As String)
Dim OBJ As Object, oShellLink As Object
Set OBJ = CreateObject("wscript.shell")
Set oShellLink = OBJ.CreateShortcut(sNom)
Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & ""
& sNom)


With oShellLink
.TargetPath = sChemin
.Arguments = sParam
.WorkingDirectory = sRepertoireDeTravail
If sIcon = "" Then sIcon = sChemin
.IconLocation = sIcon
.Description = sComment
.Save
End With
End Function

Function Raccourci(sNom As String, sChemin As String, _
Optional sParam As String, Optional sRepertoireDeTravail As String, _
Optional sIcon As String, Optional sComment As String)
Dim OBJ As Object, oShellLink As Object
Set OBJ = CreateObject("wscript.shell")
Set oShellLink = OBJ.CreateShortcut(sNom)


With oShellLink
.TargetPath = sChemin
.Arguments = sParam
.WorkingDirectory = sRepertoireDeTravail
If sIcon = "" Then sIcon = sChemin
.IconLocation = sIcon
.Description = sComment
.Save
End With
End Function

"MK" wrote in message
news:

Bonjour, ça fonctionne très bien mais si je veux envoyer le raccourci dans
un autre folder.

Dim dos As String

dos = "C:Raccourci" & no ' ou autre chemin

Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders(dos) & "" & sNom)
'mais ça fonctionne pas

Merci beaucoup de ton aide MK


Avatar
MK
Merci de ton aide.

MK


Sub Creer()
Dim no As String
Dim da As String
Dim chemin As String
Dim nom As String
Dim Commentaire As String
Dim CheminDuLien As String


no = Feuil1.Range("A1").Value
da = Feuil1.Range("A2").Value
chemin = "C:TOTO" & no & "(" & da & ")"
nom = no & "(" & da & ")" & ".Lnk"
Commentaire = chemin

MkDir chemin
' Je suis rendu là
RaccourciSurBureau nom, chemin, , , , Commentaire

CheminDuLien = "C:" & nom

Raccourci CheminDuLien, chemin, , , , Commentaire

End Sub

Function RaccourciSurBureau(sNom As String, sChemin As String, _
Optional sParam As String, Optional sRepertoireDeTravail As String, _
Optional sIcon As String, Optional sComment As String)
Dim OBJ As Object, oShellLink As Object
Set OBJ = CreateObject("wscript.shell")
Set oShellLink = OBJ.CreateShortcut(sNom)
Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders("Desktop") & ""
& sNom)


With oShellLink
.TargetPath = sChemin
.Arguments = sParam
.WorkingDirectory = sRepertoireDeTravail
If sIcon = "" Then sIcon = sChemin
.IconLocation = sIcon
.Description = sComment
.Save
End With
End Function

Function Raccourci(sNom As String, sChemin As String, _
Optional sParam As String, Optional sRepertoireDeTravail As String, _
Optional sIcon As String, Optional sComment As String)
Dim OBJ As Object, oShellLink As Object
Set OBJ = CreateObject("wscript.shell")
Set oShellLink = OBJ.CreateShortcut(sNom)


With oShellLink
.TargetPath = sChemin
.Arguments = sParam
.WorkingDirectory = sRepertoireDeTravail
If sIcon = "" Then sIcon = sChemin
.IconLocation = sIcon
.Description = sComment
.Save
End With
End Function

"MK" wrote in message
news:

Bonjour, ça fonctionne très bien mais si je veux envoyer le raccourci dans
un autre folder.

Dim dos As String

dos = "C:Raccourci" & no ' ou autre chemin

Set oShellLink = OBJ.CreateShortcut(OBJ.SpecialFolders(dos) & "" & sNom)
'mais ça fonctionne pas

Merci beaucoup de ton aide MK