1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Sub Img_dans_Commentaire()
With Application.FileDialog(msoFileDialogFilePicker)
'Indique qu'il s'ait d'ouvrir un dossier pour y sélectionner un fichier
.AllowMultiSelect = False 'Un seul Fichier possible
.InitialFileName = "C:\Users\Fanny\Documents\Pro\photos"
'Répertoire d'ouverture de la fenetre
.Filters.Clear 'Annuler les filtres au cas où
.Filters.Add Description:="Images", Extensions:="*.gif", position:=1
.Title = "Choix de l'image"
'Verification au cas ou click sur annul dans la boite + lance la boite
If .Show = -1 Then thefile = .SelectedItems(1) Else thefile = 0
End With
'signaler à la personne qu'aucun fichier n'est choisi :
If thefile = 0 Then
MsgBox ("aucun fichier image choisi")
Exit Sub
End If
Dim Commentaire As Comment
Set Commentaire = ActiveCell.AddComment
'ActiveCell.Comment.Shape.Fill.UserPicture thefile
Dim UneForme As Shape
Set UneForme = Commentaire.Shape
With UneForme
.Fill.UserPicture thefile
.ScaleHeight 1, msoFalse
.ScaleWidth 1, msoFalse
End With
End Sub |
Partager