6 réponses
pijaku
- Messages postés
- 12247
- Date d'inscription
- jeudi 15 mai 2008
- Statut
- Modérateur
- Dernière intervention
- 10 février 2021
Salut Farfadet,
Dans ton UserForm, créé un bouton de commande que tu nommeras insérer image ou ce que tu veux... double clic dessus et insère ce code :
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.InitialFileName = CurDir
.Filters.Clear
.Filters.Add Description:="Images", Extensions:="*.jpg", Position:=1
.Title = "Choix de l'image"
If .Show = -1 Then TheFile = .SelectedItems(1) Else TheFile = 0
End With
If TheFile = 0 Then MsgBox ("aucun fichier image choisi")
Range("A1").AddComment
Range("A1").Comment.Visible = True
[A1].Comment.Shape.Fill.UserPicture TheFile
Sources et plus d'infos ici
Dans ton UserForm, créé un bouton de commande que tu nommeras insérer image ou ce que tu veux... double clic dessus et insère ce code :
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.InitialFileName = CurDir
.Filters.Clear
.Filters.Add Description:="Images", Extensions:="*.jpg", Position:=1
.Title = "Choix de l'image"
If .Show = -1 Then TheFile = .SelectedItems(1) Else TheFile = 0
End With
If TheFile = 0 Then MsgBox ("aucun fichier image choisi")
Range("A1").AddComment
Range("A1").Comment.Visible = True
[A1].Comment.Shape.Fill.UserPicture TheFile
Sources et plus d'infos ici
Farfadet88
- Messages postés
- 6285
- Date d'inscription
- lundi 28 janvier 2008
- Statut
- Membre
- Dernière intervention
- 29 avril 2020
Ok ca marche!
Merci!
Merci!
Farfadet88
- Messages postés
- 6285
- Date d'inscription
- lundi 28 janvier 2008
- Statut
- Membre
- Dernière intervention
- 29 avril 2020
Petit souci, si finalement n annule et on ne veut pas d'image ben ça bug. comment faire?
pijaku
- Messages postés
- 12247
- Date d'inscription
- jeudi 15 mai 2008
- Statut
- Modérateur
- Dernière intervention
- 10 février 2021
A la place de :
If TheFile = 0 Then MsgBox ("aucun fichier image choisi")
mettre :
If TheFile = 0 Then
MsgBox ("aucun fichier image choisi")
Exit Sub
End If
Bonne question, je n'ai pas pensé à cela...
If TheFile = 0 Then MsgBox ("aucun fichier image choisi")
mettre :
If TheFile = 0 Then
MsgBox ("aucun fichier image choisi")
Exit Sub
End If
Bonne question, je n'ai pas pensé à cela...