|
-
Nov 9th, 2006, 07:52 AM
#1
Thread Starter
Fanatic Member
Excel to Outlook
Hello everyone,
I haven an excel sheet containing contact information.
In cell A1 is the firstname of the contact.
I made a button on the excel sheet. When I press it it should UPDATE the firstname in the cell to outlook contacts.
I have build some code wich ADDS a NEW contact to outlook.
That code works fine.
BUT...
I just want to change the firstname of that contact and I dont want to add a NEW contact.
I hope that you guys can help me.
VB Code:
Sub MakeContact()
Dim olApp As outlook.Application
Dim olCi As outlook.ContactItem
Set olApp = New outlook.Application
Set olCi = olApp.CreateItem(olContactItem)
With olCi
.FirstName = Cells(1, 1)
' .LastName = "Kusleika"
' .MobileTelephoneNumber = "(402) 555-1212"
' .HomeAddressStreet = "111 S 1st"
' .HomeAddressCity = "Omaha"
' .HomeAddressState = "NE"
' .HomeAddressPostalCode = "68100"
' .SelectedMailingAddress = olHome
' .Categories = "Business, Personal"
.Save
End With
Set olCi = Nothing
Set olApp = Nothing
End Sub
-
Nov 10th, 2006, 03:29 AM
#2
Lively Member
Re: Excel to Outlook
You can try something like this:
VB Code:
Dim olApp As Outlook.Application
Dim olCi As Outlook.ContactItem
Dim oCF As Outlook.MAPIFolder
Dim oNS As Outlook.NameSpace
Set olApp = New Outlook.Application
Set oNS = olApp.GetNamespace("MAPI")
Set oCF = oNS.GetDefaultFolder(olFolderContacts)
Set olCi = oCF.Items.Find("[Fullname] = " & "My name")
If TypeName(olCi) = "Nothing" Then
MsgBox "Contact does not excist, so create first one."
Else
MsgBox "Contact excists. You can edit this one"
End If
Set olCi = Nothing
Set oCF = Nothing
Set oNS = Nothing
olApp.Quit
Set olApp = Nothing
Last edited by [Pieter]; Nov 10th, 2006 at 03:46 AM.
Reason: changed way to get contact folder
Pieter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|