Private Sub Enregistrer_Click()
Dim numLigneVide As Integer
Worksheets("Liste").Activate
numLigneVide = ActiveSheet.Columns(1).Find("").Row
If Nom.Text = "" Then
MsgBox "Vueillez saisir le nom !", , "Carnet d'adresses"
Nom.SetFocus
Else
ActiveSheet.Cells(numLigneVide, 1) = Nom.Text
ActiveSheet.Cells(numLigneVide, 2) = Prénom.Text
ActiveSheet.Cells(numLigneVide, 3) = Rue.Text
ActiveSheet.Cells(numLigneVide, 4) = CP.Text
ActiveSheet.Cells(numLigneVide, 5) = Ville.Text
ActiveSheet.Cells(numLigneVide, 6) = Téléphone.Text
ActiveSheet.Cells(numLigneVide, 7) = Mobile.Text
ActiveSheet.Cells(numLigneVide, 8) = Email.Text
ActiveSheet.Cells(numLigneVide, 9) = Web.Text
Nom.Text = ""
Prénom.Text = ""
Rue.Text = ""
CP.Text = ""
Ville.Text = ""
Téléphone.Text = ""
Mobile.Text = ""
Email.Text = ""
Web.Text = ""
Nom.SetFocus
End If
'création du contact dans Outlook
Dim objOutlook As Outlook.Application
Dim objContact As ContactItem
Set objOutlook = New Outlook.Application
Set objContact = objOutlook.CreateItem(olContactItem)
Dim NomFamille As String
NomFamille = Sheets("Liste").Range("b65535").End(xlUp).Text & " " & _
Sheets("Liste").Range("a65535").End(xlUp).Text
With objContact
.FullName = NomFamille
.BusinessAddressStreet = Sheets("Liste").Range("c65535").End(xlUp).Text
.BusinessAddressPostalCode = Sheets("Liste").Range("d65535").End(xlUp).Text
.BusinessAddressCity = Sheets("Liste").Range("e65535").End(xlUp).Text
.BusinessTelephoneNumber = Sheets("Liste").Range("f65535").End(xlUp).Text
.MobileTelephoneNumber = Sheets("Liste").Range("g65535").End(xlUp).Text
.Email1Address = Sheets("Liste").Range("h65535").End(xlUp).Text
.Save
End With
Load Nouveau
End Sub