473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Open the Outlook Addressbook in VBA

Is there a way to open the MS Outlook address book using VBA and then
be able to do something with the return value?
I want users to click an icon to open the Outlook address book then
when an address is selected, populate an Access field with the address.
Is this remotely possible?
Thanks,
lq

Nov 13 '05 #1
4 17441
lauren quantrell wrote:
Is there a way to open the MS Outlook address book using VBA and then
be able to do something with the return value?
I want users to click an icon to open the Outlook address book then
when an address is selected, populate an Access field with the address.
Is this remotely possible?
Thanks,
lq

Yes I believe such is doable. However, I have only used Access/VBA to
extract messages from Outlook. YOu want to search out information on
Microsoft Office Interoperability. I have a guide published by Microsoft:
"Microsoft Office 2000 Automation" - "Your guide to Microsoft Office
2000 Interoperability".

I suggest you search on those keywords.

Also, the following links may help:

http://www.programmingmsaccess.com/S...FromAccess.htm

http://support.microsoft.com/default...;en-us;Q253794

http://www.slipstick.com/addins/mail.htm

http://www.slovaktech.com/code_sampl...ripAttachments

http://support.microsoft.com/?kbid=220595

Have fun.

Bob
Nov 13 '05 #2
One thing you could do-
link to the Address book (or I guess use IN in your query...) and then
use the Address Book in a combobox or something... something like:

SELECT olkContacts.Last & ", " & olkContacts.First AS Contact FROM
olkContacts ORDER BY olkContacts.Last & ", " & olkContacts.First;

If you put all the information you want in various columns of your
combobox, you can refer to the columns using
[some text field] = cboOLKContact.Columns(0)

or some such thing.

Hope it helps some.
Pieter

Nov 13 '05 #3
Br
lauren quantrell <la*************@hotmail.com> wrote:
Is there a way to open the MS Outlook address book using VBA and then
be able to do something with the return value?
I want users to click an icon to open the Outlook address book then
when an address is selected, populate an Access field with the
address. Is this remotely possible?
Thanks,
lq


I have programmed a routine that works the other way and creates an
Outlook Address Book from Access data... so I'm sure you can do the
opposite.

Below is my code which may be hepful?
Function CreateOutlookContacts()
On Error GoTo CreateOutlookContacts_err

'prompt user
Dim r As Long, myMsg As String
r = MsgBox("BIGCare will create a 'BIGCare Contacts' folder in
Microsoft Outlook. Continue?", vbQuestion + vbOKCancel +
vbDefaultButton1, "Outlook Contacts")
If r <> vbOK Then Exit Function

Dim rsPerson As DAO.Recordset
Dim CountTotal As Long, CountRec As Long, OutputForm As String, i As
Long
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myContactFolder As Outlook.MAPIFolder
Dim myItem As Outlook.ContactItem
Dim myOlBar As Outlook.OutlookBarPane
Dim myOlGroup As Outlook.OutlookBarGroup
Dim myOlBarShortcut As Outlook.OutlookBarShortcut
Dim myExplorer As Outlook.Explorer
Set rsPerson = CurrentDb.OpenRecordset("qryOutlookExport",
DB_OPEN_SNAPSHOT)
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)

'Check some people records exist
If rsPerson.RecordCount = 0 Then Exit Function
rsPerson.MoveLast
CountTotal = rsPerson.RecordCount
CountRec = 0
OutputForm = "frmOutlookProgress"
DoCmd.OpenForm OutputForm
GV_CANCEL = False

'Initial progress message
Forms(OutputForm)![lblStatus].Caption = "Deleting BIGCare Contacts
folder..."
Forms(OutputForm).Repaint

'Contact Folder

'Delete contacts folder
For i = 1 To myFolder.Folders.Count
If myFolder.Folders.Item(i).Name = "BIGCare Contacts" Then
myFolder.Folders.Remove (i)
Exit For
End If
Next

'Create folder
Set myContactFolder = myFolder.Folders.Add("BIGCare Contacts",
olFolderContacts)

'Shortcut
Set myExplorer = myOlApp.ActiveExplorer
If TypeName(myExplorer) = "Nothing" Then 'test if Outlook open
already
Set myExplorer = myFolder.GetExplorer
End If
Set myOlBar = myExplorer.Panes.Item("OutlookBar")
Set myOlGroup = myOlBar.Contents.Groups.Item(1)

'check if shortcut alrady exists and delete
For i = 1 To myOlGroup.Shortcuts.Count
If myOlGroup.Shortcuts.Item(i).Name = "BIGCare Contacts" Then
myOlGroup.Shortcuts.Remove (i)
Exit For
End If
Next

'Create shortcut
Set myOlBarShortcut = myOlGroup.Shortcuts.Add(myContactFolder,
"BIGCare Contacts")

On Error GoTo CreateOutlookContacts_err
'Create contacts from people records
rsPerson.MoveFirst
Do Until rsPerson.EOF Or GV_CANCEL
If apiGetAsyncKeyState(VK_ESCAPE) Then GV_CANCEL = True 'give user
option to cancel
Set myItem = myContactFolder.Items.Add(olContactItem)
If Len(rsPerson![GivenName]) > 0 Then myItem.FirstName =
rsPerson![GivenName]
If Len(rsPerson![SurnameSCR]) > 0 Then myItem.LastName =
rsPerson![SurnameSCR]
If Len(rsPerson![email]) > 0 Then myItem.Email1Address =
rsPerson![email]
If Len(rsPerson![HomePhone]) > 0 Then myItem.HomeTelephoneNumber =
rsPerson![HomePhone]
If Len(rsPerson![WorkPhone]) > 0 Then myItem.BusinessTelephoneNumber
= rsPerson![WorkPhone]
If Len(rsPerson![MobilePhone]) > 0 Then myItem.MobileTelephoneNumber
= rsPerson![MobilePhone]
If Len(rsPerson![HomeFax]) > 0 Then myItem.HomeFaxNumber =
rsPerson![HomeFax]
If Len(rsPerson![WorkFax]) > 0 Then myItem.BusinessFaxNumber =
rsPerson![WorkFax]
If Len(rsPerson![Address1]) > 0 Then myItem.HomeAddressStreet =
rsPerson![Address1]
If Len(rsPerson![Address2]) > 0 Then myItem.HomeAddressStreet =
rsPerson![Address2]
If Len(rsPerson![Suburb]) > 0 Then myItem.HomeAddressCity =
rsPerson![Suburb]
If Len(rsPerson![Country]) > 0 Then myItem.HomeAddressCountry =
rsPerson![Country]
If Len(rsPerson![PostCode]) > 0 Then myItem.HomeAddressPostalCode =
rsPerson![PostCode]
If Len(rsPerson![PostalAddress1]) > 0 Then
myItem.MailingAddressStreet = rsPerson![PostalAddress1]
If Len(rsPerson![PostalAddress2]) > 0 Then
myItem.MailingAddressStreet = rsPerson![PostalAddress2]
If Len(rsPerson![PostalSuburb]) > 0 Then myItem.MailingAddressCity =
rsPerson![PostalSuburb]
If Len(rsPerson![PostalCountry]) > 0 Then
myItem.MailingAddressCountry = rsPerson![PostalCountry]
If Len(rsPerson![PostalPostCode]) > 0 Then
myItem.MailingAddressPostalCode = rsPerson![PostalPostCode]
myItem.Save
'Update progress indicator
CountRec = CountRec + 1
Forms(OutputForm)![lblStatus].Caption = CountRec & " of " &
CountTotal
Forms(OutputForm)![bxProgress].Width = (8 / CountTotal) * CountRec *
567
Forms(OutputForm).Repaint
rsPerson.MoveNext
Loop

If GV_CANCEL Then
Forms(OutputForm)!lblEscape.Caption = "Cancelled"
Else
Forms(OutputForm)!lblEscape.Caption = "Done"
End If
Forms(OutputForm)![btnOK].Visible = True

myMsg = "To make the Contact Folder appear in your Address Book please
do the following: " & Chr(10)
myMsg = myMsg & Chr(10) & "- Right-click on the 'BIGCare Contacts'
shortcut in Outlook"
myMsg = myMsg & Chr(10) & "- Select 'Properties' from the menu"
myMsg = myMsg & Chr(10) & "- Under the 'Outlook Address Book' tab tick
the box"
myMsg = myMsg & Chr(10) & " labelled 'Show this folder as an e-mail
Address Book'"
myMsg = myMsg & Chr(10) & "- Click 'OK'"
MsgBox myMsg, vbInformation + vbOKOnly, "Outlook Contacts"

CreateOutlookContacts_exit:

'Clean up
Set myExplorer = Nothing
Set myOlBarShortcut = Nothing
Set myOlGroup = Nothing
Set myOlBar = Nothing
Set myItem = Nothing
Set myContactFolder = Nothing
Set myFolder = Nothing
Set myNameSpace = Nothing
Set myOlApp = Nothing
Set rsPerson = Nothing

Exit Function

CreateOutlookContacts_err:
MsgBox err.Description, 48, "Error in CreateOutlookContacts()"
Resume CreateOutlookContacts_exit
End Function

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #4
Pieter,
That seems like a good solution with an MDB but I'm using an ADP with a
SQL server backend. As far as I know I can't link to a user's Outlook
Address Book...

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michi | last post by:
Hello there I try to access the Outlook/Outlook Express AddressBook with the MAPISession/MAPIMessage Components. Depending on the registry setting. I can tell the sytem which AddressBook it...
2
by: someone | last post by:
Hi, I currently have an Access 97 database that includes a field for contact name of a user. This user will almost always have a valid email address contained in the personal address book of...
1
by: Lauren Quantrell | last post by:
I know if I was using an Access MDB I could link to MS Outlook folders and the addressbook. But I'm using an Access Project (ADP) and want to figure out a way to link to the Outlook addressbook...
4
by: Ecohouse | last post by:
I need to be able to access an Outlook folder and read each email and pull data from the email into tables in Access and move the email to another folder. I now about automation but am not sure...
0
by: Elad | last post by:
Hi For a long time I'm trying to open the outlook address book with asp.net application, I have tried many ways suggested in this group but it doesn't work - I cant create MAPI session, Does...
1
by: LeAnne | last post by:
Does anyone know how i could display a MS Outlook screen which can be used for the user to select a contact. I need a screen to display the outlook contacts and for the user to select one of them...
4
by: omrivm | last post by:
Hi, I have a problem with Outlook Redemption, every time I'm trying to create a new RDOAddressBook: Redemption.RDOAddressBook AB = new RDOAddressBook(); I get: "Retrieving the COM class factory...
0
by: Gnana | last post by:
Following is the piece of code i got from this forum itself but stil i am not able to get the full details of recepients like location,office number. plz help me to access that information.. ...
0
by: Roman Optio | last post by:
Hi, I am currently working on a tool to transfer addressbook data such as contacts and organizations between Vondle and Outlook. For those of you who are wondering what Vondle is, it is an...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.