473,606 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 17458
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 Interoperabilit y. I have a guide published by Microsoft:
"Microsoft Office 2000 Automation" - "Your guide to Microsoft Office
2000 Interoperabilit y".

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.Las t & ", " & olkContacts.Fir st AS Contact FROM
olkContacts ORDER BY olkContacts.Las t & ", " & olkContacts.Fir st;

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.C olumns(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 CreateOutlookCo ntacts()
On Error GoTo CreateOutlookCo ntacts_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 +
vbDefaultButton 1, "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.Applica tion
Dim myNameSpace As Outlook.NameSpa ce
Dim myFolder As Outlook.MAPIFol der
Dim myContactFolder As Outlook.MAPIFol der
Dim myItem As Outlook.Contact Item
Dim myOlBar As Outlook.Outlook BarPane
Dim myOlGroup As Outlook.Outlook BarGroup
Dim myOlBarShortcut As Outlook.Outlook BarShortcut
Dim myExplorer As Outlook.Explore r
Set rsPerson = CurrentDb.OpenR ecordset("qryOu tlookExport",
DB_OPEN_SNAPSHO T)
Set myOlApp = CreateObject("O utlook.Applicat ion")
Set myNameSpace = myOlApp.GetName space("MAPI")
Set myFolder = myNameSpace.Get DefaultFolder(o lFolderContacts )

'Check some people records exist
If rsPerson.Record Count = 0 Then Exit Function
rsPerson.MoveLa st
CountTotal = rsPerson.Record Count
CountRec = 0
OutputForm = "frmOutlookProg ress"
DoCmd.OpenForm OutputForm
GV_CANCEL = False

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

'Contact Folder

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

'Create folder
Set myContactFolder = myFolder.Folder s.Add("BIGCare Contacts",
olFolderContact s)

'Shortcut
Set myExplorer = myOlApp.ActiveE xplorer
If TypeName(myExpl orer) = "Nothing" Then 'test if Outlook open
already
Set myExplorer = myFolder.GetExp lorer
End If
Set myOlBar = myExplorer.Pane s.Item("Outlook Bar")
Set myOlGroup = myOlBar.Content s.Groups.Item(1 )

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

'Create shortcut
Set myOlBarShortcut = myOlGroup.Short cuts.Add(myCont actFolder,
"BIGCare Contacts")

On Error GoTo CreateOutlookCo ntacts_err
'Create contacts from people records
rsPerson.MoveFi rst
Do Until rsPerson.EOF Or GV_CANCEL
If apiGetAsyncKeyS tate(VK_ESCAPE) Then GV_CANCEL = True 'give user
option to cancel
Set myItem = myContactFolder .Items.Add(olCo ntactItem)
If Len(rsPerson![GivenName]) > 0 Then myItem.FirstNam e =
rsPerson![GivenName]
If Len(rsPerson![SurnameSCR]) > 0 Then myItem.LastName =
rsPerson![SurnameSCR]
If Len(rsPerson![email]) > 0 Then myItem.Email1Ad dress =
rsPerson![email]
If Len(rsPerson![HomePhone]) > 0 Then myItem.HomeTele phoneNumber =
rsPerson![HomePhone]
If Len(rsPerson![WorkPhone]) > 0 Then myItem.Business TelephoneNumber
= rsPerson![WorkPhone]
If Len(rsPerson![MobilePhone]) > 0 Then myItem.MobileTe lephoneNumber
= rsPerson![MobilePhone]
If Len(rsPerson![HomeFax]) > 0 Then myItem.HomeFaxN umber =
rsPerson![HomeFax]
If Len(rsPerson![WorkFax]) > 0 Then myItem.Business FaxNumber =
rsPerson![WorkFax]
If Len(rsPerson![Address1]) > 0 Then myItem.HomeAddr essStreet =
rsPerson![Address1]
If Len(rsPerson![Address2]) > 0 Then myItem.HomeAddr essStreet =
rsPerson![Address2]
If Len(rsPerson![Suburb]) > 0 Then myItem.HomeAddr essCity =
rsPerson![Suburb]
If Len(rsPerson![Country]) > 0 Then myItem.HomeAddr essCountry =
rsPerson![Country]
If Len(rsPerson![PostCode]) > 0 Then myItem.HomeAddr essPostalCode =
rsPerson![PostCode]
If Len(rsPerson![PostalAddress1]) > 0 Then
myItem.MailingA ddressStreet = rsPerson![PostalAddress1]
If Len(rsPerson![PostalAddress2]) > 0 Then
myItem.MailingA ddressStreet = rsPerson![PostalAddress2]
If Len(rsPerson![PostalSuburb]) > 0 Then myItem.MailingA ddressCity =
rsPerson![PostalSuburb]
If Len(rsPerson![PostalCountry]) > 0 Then
myItem.MailingA ddressCountry = rsPerson![PostalCountry]
If Len(rsPerson![PostalPostCode]) > 0 Then
myItem.MailingA ddressPostalCod e = rsPerson![PostalPostCode]
myItem.Save
'Update progress indicator
CountRec = CountRec + 1
Forms(OutputFor m)![lblStatus].Caption = CountRec & " of " &
CountTotal
Forms(OutputFor m)![bxProgress].Width = (8 / CountTotal) * CountRec *
567
Forms(OutputFor m).Repaint
rsPerson.MoveNe xt
Loop

If GV_CANCEL Then
Forms(OutputFor m)!lblEscape.Ca ption = "Cancelled"
Else
Forms(OutputFor m)!lblEscape.Ca ption = "Done"
End If
Forms(OutputFor m)![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"

CreateOutlookCo ntacts_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

CreateOutlookCo ntacts_err:
MsgBox err.Description , 48, "Error in CreateOutlookCo ntacts()"
Resume CreateOutlookCo ntacts_exit
End Function

--
regards,

Bradley

A Christian Response
http://www.pastornet.n et.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
3644
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 should load. HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\ >(Standard)->Outlook Express or
2
2732
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 the person who inputs the records into the database. At present the person inputting the records has to manually look up the correct address and copy in into the field. I know that it should be possible to lookup that address by some form of...
1
2975
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 this in code. I'm hoping someone has an example of how to accomplish this, through CDO or otherwise. Thanks, lq
4
5575
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 exactly how to do it for Outlook. Below is an example of an email that I need to pull the data from: DATE/TIME: 8/25/2005 1:57:15 PM
0
1899
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 any one have a working example for it ? ( I'm using outlook 2000, asp.net 2002/2003, CDO 1.21 ) Elad
1
1812
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 and this screen should return the selected contact. Then i should be able to get the details of this selected contact. Any idea???
4
10305
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 for component with CLSID {...GUID...} failed due to the following error: 80040154." I tried to reregister the Redemption DLL but I still get this exception... My OS is win server 2003 sp1 it may be the problem?
0
1877
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.. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;
0
2263
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 online project management toolkit used to support large engineering projects. More information on Vondle can be found at http://www.bricsys.com/vondle/ . The purpose of the tool is to fluently transfer addressbook data between vondle & outlook. I've...
0
8036
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8461
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8126
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5470
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3948
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2454
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1313
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.