Bonjour à tous,
Je suis un petit nouveau dans le VBA, veuillez m'excusez par avances.
J'ai quelques petit soucis sur la récupération d'information. J'ai inséré un image sur une feuille de mon classeur grace a une boite de dialogue mais je n'arrive ni a récupéré le nom du fichier, ni son chemin une fois celle ci inséré.
Pourriez vous m'aider svp.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
29
30
31
32
33
34
35
36
37
38
39
40 Sub Insert_image() Dim Emplacement As Range Dim Img As Object 'Dim Repertoire As FileDialog' Dim ShapeObj As Shape Dim Nom_img As String Dim Chemin_img As String 'Boucle pour supprimer l'ancienne image For Each ShapeObj In ActiveSheet.Shapes If ShapeObj.Name = "ImageActive" Then ActiveSheet.Shapes("ImageActive").Delete Next ShapeObj 'Ouverture de la boite de dialogue' If Application.Dialogs(xlDialogInsertPicture).Show Then 'Définit l'emplacement de l'image Set Emplacement = Range("F2:M25") Set Img = ActiveSheet.DrawingObjects(ActiveSheet.Shapes.Count) 'Récupération du nom de l'image Nom_img = Img.Name 'Récupération du chemin Chem_img = Img.Path With Img.ShapeRange .LockAspectRatio = msoFalse .Left = Emplacement.Left .Top = Emplacement.Top .Height = Emplacement.Height .Width = Emplacement.Width End With MsgBox "Insertion d'image effectué - Image insertion performed." Else MsgBox "Insertion d'image interrompue / Interrupted image insertion." End If
Partager