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 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Sub InsertionImages()
Dim Repertoire As String
Dim Extension As String
Dim Fichier As String
'Saisie du nom du répertoire
Repertoire = InputBox("Chemin complet du répertoire (\ à la fin)", "Répertoire", "D:\test\")
If Repertoire = "" Then Exit Sub
'Saisie du type d'extension
Extension = InputBox("Type de fichier (sans le point, ex : jpg, png, bmp)", "Type de fichier", "jpg")
If Extension = "" Then Exit Sub
'Récupération du premier fichier du répertoire
Fichier = Dir(Repertoire & "*" & Extension, vbDirectory)
L = -3
c = 4
Do While Fichier <> ""
i = i + 1
'Insertion de l'image
L = L + 5
'Verification 3 photos
If L = 17 Then
c = c + 13
L = 2
End If
ActiveSheet.Pictures.Insert(Repertoire & Fichier).Select
'Selection.Name = monimage & L
Selection.Name = Fichier
Selection.ShapeRange.LockAspectRatio = msoFalse
'With ActiveSheet.Shapes(monimage & L)
With ActiveSheet.Shapes(Fichier)
.Top = Cells(c, L).Top
.Left = Cells(c, L).Left
.Height = Range(Cells(c, L), Cells(c + 11, L)).Height
.Width = Range(Cells(c, L), Cells(c, L + 4)).Width
End With
Range("L18").Select
Fichier = Dir
Loop
End Sub |
Partager