add or update contact from Excel to Outlook

cenky

New Member
Joined
Jul 30, 2014
Messages
10
Hello friends,

I have very well working code to add contact from Excel worksheet to Outlook, however I am facing problem - want to update the contact if already exists (for instance contact which has same emailadress as the one i have in my excel worksheet).
Will somebody help me how to modificate my code tnot only to add new contact but also to update the contact if already exist.

Thank you in advance!

Here is my code:
Sub Add_contact_to_Outlook()

Dim applOutlook As Outlook.Application
Dim nsOutlook As Outlook.Namespace
Dim ciOutlook As Outlook.ContactItem
Dim delFolder As Outlook.Folder
Dim delItems As Outlook.Items
Dim lLastRow As Long, i As Long, n As Long, c As Long

Set applOutlook = New Outlook.Application

Set nsOutlook = applOutlook.GetNamespace("MAPI")

Set ciOutlook = applOutlook.CreateItem(olContactItem)

ciOutlook.Display

With ciOutlook
.FirstName = Sheets("Sheet1").Cells(72, 16)
.LastName = Sheets("Sheet1").Cells(72, 20)
.Email1Address = Sheets("Sheet1").Cells(78, 16)
.MobileTelephoneNumber = Sheets("Sheet1").Cells(76, 16)
.Birthday = Sheets("Sheet1").Cells(24, 13)
End With

ciOutlook.Close olSave

Set applOutlook = Nothing
Set nsOutlook = Nothing
Set ciOutlook = Nothing
Set delFolder = Nothing
Set delItems = Nothing

End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Get a reference to the Contacts folder using NameSpace.GetDefaultFolder(olFolderContacts), then use theContactsFolder.Items.Find or theContactsFolder.Items.Restrict using the filter string syntax shown in the Outlook VBA Help.
 
Upvote 0
Get a reference to the Contacts folder using NameSpace.GetDefaultFolder(olFolderContacts), then use theContactsFolder.Items.Find or theContactsFolder.Items.Restrict using the filter string syntax shown in the Outlook VBA Help.

Hello John,

thank you for your reply. Will you please try to write your idea into my code? I have no clue how to do it.:(

Thank you in advance!

Ivan
 
Upvote 0

Forum statistics

Threads
1,216,750
Messages
6,132,500
Members
449,730
Latest member
SeanHT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top