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
| Private Sub Commande98_Click()
Dim strLink As String
' Gestion des erreurs
On Error GoTo Catch01
' récupération du chemin physique de la photo
' par la boite de dialogue
strLink = openfile(Me.Hwnd, "Sélectionner une photo pour le salarié" & Me.ref_site, 1)
' si la boite renvoie une adresse non nulle
If Len(strLink) > 0 Then
' tentative d'affichage de la photo
Me.imgPhoto.Picture = strLink
Me.photo = strLink
End If
DisplayPhoto
Exit Sub
Catch01:
Select Case Err.Number
Case 2114
'Cas d'un type de fichier photo non supporté ...
' on sort de la procédure
MsgBox "Le format de l'image n'est supporté par le contrôle image Picture", vbCritical + vbOKOnly, "Application Photos"
Exit Sub
Case 2220
'Cas d'un emplacement non valide du fichier images
MsgBox "Le fichier image n'a pas été trouvé à l'emplacement indiqué : " & vbCrLf & _
Me.photo, vbCritical + vbOKOnly, "Application Photos"
Exit Sub
Case Else
' tout autre cas d'erreur
MsgBox "Erreur inattendue : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "Application Photos"
End Select
Err.Clear
End Sub |