-
Button in Excel to open a New Contact in Outlook
I have a Vendor Distribution list which I created by writing some VBA code which goes out to a public folder in outlook and retrieves the contact names, company name, phone number, etc. I would like to create two form buttons in excel - one would open the contact in outlook that is currently active in excel and the other button would open a New Contact dialog box in outlook. Any idea on how I would go about find the commands to either retrieve or create a new contact in Outlook from Excel? Thanks.
-
this may help - add whatever contact details you require
[vba]Sub GetContact()
Dim myExcelname As String
Dim myOL As Outlook.Application
Dim myMapi As Outlook.Namespace
Dim myfolder As Outlook.MAPIFolder
Dim mycontact As Outlook.ContactItem
Set myOL = CreateObject("Outlook.application")
Set myMapi = myOL.GetNamespace("MAPI")
Set myfolder = myMapi.GetDefaultFolder(olFolderContacts)
Set mycontact = myOL.CreateItem(olContactItem)
myExcelname = Cells(1, 1).Value
For Each mycontact In myfolder.Items
If mycontact.FullName = myExcelname Then
Cells(2, 1) = mycontact.FullName
Cells(3, 1) = mycontact.CompanyName
Cells(4, 1) = mycontact.HomeTelephoneNumber
Cells(5, 1) = mycontact.Email1DisplayName
End If
Next
Set myOL = Nothing
End Sub
Sub AddContact()
Dim myOL As Outlook.Application
Dim myMapi As Outlook.Namespace
Dim myfolder As Outlook.MAPIFolder
Dim mycontact As Outlook.ContactItem
Set myOL = CreateObject("Outlook.application")
Set myMapi = myOL.GetNamespace("MAPI")
Set myfolder = myMapi.GetDefaultFolder(olFolderContacts)
Set mycontact = myOL.CreateItem(olContactItem)
With mycontact
.FullName = "MY NAME"
.Email1DisplayName = "MY EMAIL"
.CompanyName = "MY COMPANY"
.HomeTelephoneNumber = "MY HOME No."
.Save
End With
Set myOL = Nothing
End Sub
[/vba]
regards
qff
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