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 55 56 57 58 59 60
| Public i As Integer
Private Sub UserForm_Initialize ()
i = 1
End Sub
Private Sub parcourir_Click()
Dim Photo As Variant
Dim Gauche, Sommet, Largeur, Hauteur As Single
Dim TheFile As Variant
Dim ThePath As String
Dim UserDir As String
Application.ScreenUpdating = False
ThePath = "C:\Mes Documents\"
TheFile = Application.GetOpenFilename("Fichiers bmp/gif/jpg/tiff,*.bmp;*.gif;*.jpg;*.jpeg;*.tiff")
If TheFile = False Then ChDir UserDir: Exit Sub
With Me.Image_logo
.Picture = LoadPicture(TheFile)
.Tag = TheFile
.PictureSizeMode = fmPictureSizeModeZoom
End With
dernier_ligne = 3
Do
If Sheets("bd").Cells(dernier_ligne, 2).Value <> "" Then dernier_ligne = dernier_ligne + 1
Loop Until Sheets("bd").Cells(dernier_ligne, 2).Value = ""
Sheets("bd").Select
Cells(dernier_ligne, 1).Select
Gauche = Range("A" & dernier_ligne).Left
Sommet = Range("A" & dernier_ligne).Top
Largeur = Range("A" & dernier_ligne).Width
Hauteur = Range("A" & dernier_ligne).Height
If TheFile <> False Then
With ActiveSheet
.Pictures.Insert(TheFile).Name = "image" & i
.Shapes("image" & i).Height = Hauteur
.Shapes("image" & i).Left = Gauche + ((ActiveCell.Width - ActiveSheet.Shapes("image" & i).Width) / 2)
.Shapes("image" & i).Top = Sommet
.Shapes("image" & i).LockAspectRatio = msoTrue
End With
'Feuil2.Shapes.AddPicture TheFile, True, True, Gauche, Sommet, Largeur, Hauteur
'Feuil2.Shapes(1).LockAspectRatio = msoTrue
End If
'ChDir UserDir
Sheets("accueil").Select
Application.ScreenUpdating = True
i = i + 1
End Sub |
Partager