Option Explicit
Private Sub UserForm_Initialize()
With Me
.OptionButton1.Caption = 'Fichiers GIF'
.OptionButton2.Caption = 'Fichiers JPG'
End With
End Sub
Private Sub CommandButton1_Click()
Dim TheFile As Variant
Dim ThePath As String
Dim UserDir As String
Dim Extention As String
Extention = IIf(Me.OptionButton1 = True, '*.gif', '*.jpg')
ThePath = 'C:\\Mes Documents\\' 'a ajuster au répertoire contenant tes images
UserDir = CurDir
On Error Resume Next 'si le path n'existe pas (non ajusté ci dessus)
ChDir ThePath
On Error GoTo 0
TheFile = Application.GetOpenFilename('image(' & Extention & '),' & Extention & '')
If TheFile = False Then ChDir UserDir: Exit Sub
With Me.Image1
.Picture = LoadPicture(TheFile)
.PictureSizeMode = fmPictureSizeModeZoom
End With
ChDir UserDir
End Sub