I found this proven VB code on the internet, copy/pasted it but I get a "Method or data member not found" error on the line SET OLA=APPLICATION.SESSION... What am I doing wrong? Thanks -Ken.
Only needs "Microsoft Outlook xx.x Object Library - I used 11.0) - Private Sub cmdAddress_Book_Click()
-
'---- create an listbox (I named it ab - Address Book)
-
Dim ola As Outlook.AddressList
-
Dim ole As Outlook.AddressEntry
-
-
On Error Resume Next
-
Set ola = Application.Session.AddressLists("Contacts")
-
For Each ole In ola.AddressEntries
-
ab.AddItem ole
-
Next
-
Set ola = Nothing
-
Set ole = Nothing
-
End Sub
8 5843
I found this proven VB code on the internet, copy/pasted it but I get a "Method or data member not found" error on the line SET OLA=APPLICATION.SESSION... What am I doing wrong? Thanks -Ken.
Only needs "Microsoft Outlook xx.x Object Library - I used 11.0)
Private Sub cmdAddress_Book_Click()
'---- create an listbox (I named it ab - Address Book)
Dim ola As Outlook.AddressList
Dim ole As Outlook.AddressEntry
On Error Resume Next
Set ola = Application.Session.AddressLists("Contacts")
For Each ole In ola.AddressEntries
ab.AddItem ole
Next
Set ola = Nothing
Set ole = Nothing
End Sub
I can't see how this code would ever work, since you have not fully qualified the Outlook Application Object. The code fails on this line because it expects to find a Method or Property of the Access Application Object, not Outlook, named Session. Of course this Property/Method does not exist. Once you indicate that you are explicitly referring to the Outlook Application Object (Lines 6 and 10), then then Session is a valid Property, and the code should now execute correctly. Be advised that I had no actual way of testing this Theory, I'm just assuming that it is correct. -
'---- create an listbox (I named it ab - Address Book)
-
Dim outApp As Outlook.Application
-
Dim ola As Outlook.AddressList
-
Dim ole As Outlook.AddressEntry
-
-
Set outApp = New Outlook.Application
-
-
On Error Resume Next
-
-
Set ola = outApp.Session.AddressLists("Contacts")
-
-
For Each ole In ola.AddressEntries
-
ab.AddItem ole
-
Next
-
-
outApp.Close
-
-
Set outApp = Nothing
-
Set ola = Nothing
-
Set ole = Nothing
I can't see how this code would ever work, since you have not fully qualified the Outlook Application Object. The code fails on this line because it expects to find a Method or Property of the Access Application Object, not Outlook, named Session. Of course this Property/Method does not exist. Once you indicate that you are explicitly referring to the Outlook Application Object (Lines 6 and 10), then then Session is a valid Property, and the code should now execute correctly. Be advised that I had no actual way of testing this Theory, I'm just assuming that it is correct. -
'---- create an listbox (I named it ab - Address Book)
-
Dim outApp As Outlook.Application
-
Dim ola As Outlook.AddressList
-
Dim ole As Outlook.AddressEntry
-
-
Set outApp = New Outlook.Application
-
-
On Error Resume Next
-
-
Set ola = outApp.Session.AddressLists("Contacts")
-
-
For Each ole In ola.AddressEntries
-
ab.AddItem ole
-
Next
-
-
outApp.Close
-
-
Set outApp = Nothing
-
Set ola = Nothing
-
Set ole = Nothing
Oh great one, You are correct. My next problem is that the for/next loop finds nothing to add. Is the actual name of MS OutLook Express address book called "Contacts"? I tried Contacts, MyContacts, and even some junk like DFGOIJEGUG and I keep getting the same result. Thanks -Ken.
Oh great one, You are correct. My next problem is that the for/next loop finds nothing to add. Is the actual name of MS OutLook Express address book called "Contacts"? I tried Contacts, MyContacts, and even some junk like DFGOIJEGUG and I keep getting the same result. Thanks -Ken.
Again, I have no way to test this, but the following code should list all the entries in the Outlook Address Book, and Print them to the Immediate Window, I think (LOL). -
Dim outApp As Outlook.Application
-
Dim ola As Outlook.AddressList
-
Dim intCounter As Integer
-
-
Set outApp = New Outlook.Application
-
-
On Error Resume Next
-
-
For intCounter = 1 To outApp.Session.AddressLists.Count
-
Debug.Print "Address List Entry #" & intCounter & ": " & _
-
outApp.Session.AddressLists(intCounter).Name
-
Next
-
-
Set outApp = Nothing
-
Set ola = Nothing
-
Set ole = Nothing
Again, I have no way to test this, but the following code should list all the entries in the Outlook Address Book, and Print them to the Immediate Window, I think (LOL). -
Dim outApp As Outlook.Application
-
Dim ola As Outlook.AddressList
-
Dim intCounter As Integer
-
-
Set outApp = New Outlook.Application
-
-
On Error Resume Next
-
-
For intCounter = 1 To outApp.Session.AddressLists.Count
-
Debug.Print "Address List Entry #" & intCounter & ": " & _
-
outApp.Session.AddressLists(intCounter).Name
-
Next
-
-
Set outApp = Nothing
-
Set ola = Nothing
-
Set ole = Nothing
Oh great one, You are correct AGAIN. The address books name is "Global Address List" OutLook took noticed that I was looking at the address book because it put up a Window informing me that someone was trying to get to my address book and was that OK with me. "Contacts" never got a rise from OutLook!!! My same problem is still that the for/next loop finds nothing to add. Thanks -Ken.
Oh great one, You are correct AGAIN. The address books name is "Global Address List" OutLook took noticed that I was looking at the address book because it put up a Window informing me that someone was trying to get to my address book and was that OK with me. "Contacts" never got a rise from OutLook!!! My same problem is still that the for/next loop finds nothing to add. Thanks -Ken.
BTW, thanks but absolutely no need for the great one reference. Try these 2 approaches to the problem, and see which, if either one, works: -
'---- create an listbox (I named it ab - Address Book)
-
Dim outApp As Outlook.Application
-
Dim ola As Outlook.AddressList
-
Dim ole As Outlook.AddressEntry
-
Dim intNumOfEntries As Integer
-
-
Set outApp = New Outlook.Application
-
-
On Error Resume Next
-
-
Set ola = outApp.Session.AddressLists("Global Address List")
-
-
'Try this method first
-
For Each ole In ola.AddressEntries
-
Me![ab].AddItem ole.Name
-
Next
-
-
'Try this Method if the first does not work
-
For intNumOfEntries = 1 To ola.AddressEntries.Count
-
Me![ab].AddItem ola.AddressEntries(intNumOfEntries).Name
-
Next
-
-
Set outApp = Nothing
-
Set ola = Nothing
-
Set ole = Nothing
NOTE: I'm assuming you have either a List or Combo Box named ab on the Active Form and that you are using Access 2002 or greater in order to use the AddItem Method. Are these references True?
BTW, thanks but absolutely no need for the great one reference. Try these 2 approaches to the problem, and see which, if either one, works: -
'---- create an listbox (I named it ab - Address Book)
-
Dim outApp As Outlook.Application
-
Dim ola As Outlook.AddressList
-
Dim ole As Outlook.AddressEntry
-
Dim intNumOfEntries As Integer
-
-
Set outApp = New Outlook.Application
-
-
On Error Resume Next
-
-
Set ola = outApp.Session.AddressLists("Global Address List")
-
-
'Try this method first
-
For Each ole In ola.AddressEntries
-
Me![ab].AddItem ole.Name
-
Next
-
-
'Try this Method if the first does not work
-
For intNumOfEntries = 1 To ola.AddressEntries.Count
-
Me![ab].AddItem ola.AddressEntries(intNumOfEntries).Name
-
Next
-
-
Set outApp = Nothing
-
Set ola = Nothing
-
Set ole = Nothing
NOTE: I'm assuming you have either a List or Combo Box named ab on the Active Form and that you are using Access 2002 or greater in order to use the AddItem Method. Are these references True?
I am using XP, Access 2003, and a List Box. When you helped me find the name of the OutLook Address Book, I only got one NAME back from that routine("Global Address List"). I was always wondering why I had not gotten more NAME's because I have several folders of e-mail addresses. "ola.AddressEntries.Count" = 0. Apparently I found an Address Book but its empty? Thanks -Ken.
I am using XP, Access 2003, and a List Box. When you helped me find the name of the OutLook Address Book, I only got one NAME back from that routine("Global Address List"). I was always wondering why I had not gotten more NAME's because I have several folders of e-mail addresses. "ola.AddressEntries.Count" = 0. Apparently I found an Address Book but its empty? Thanks -Ken.
Everytime I mention OutLook, I am talking about OutLook Express. Is this my problem all along? Ken
Everytime I mention OutLook, I am talking about OutLook Express. Is this my problem all along? Ken
I honestly cannot say one way or the other, Ken.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Iain Miller |
last post by:
Currently using & developing a new application in A97. This app has a lot of
Name & Address information in it. A lot of that information will be
duplicated in Outlook & I suddenly wondered if its...
|
by: Phil Stanton |
last post by:
Can anyone give me sone code to add addresses from a query to an Outlook
Address book. The problem is that I want to add the new email addresses to a
distribution list, not to the main email list
...
|
by: jmacione |
last post by:
Problem Statement: Mary wants to share a distribution list of
approximately 1000-2000 people with 3 other people.
Sorfar I found three forms of address books that we can use for this.
1. ...
|
by: lauren quantrell |
last post by:
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...
|
by: Bob Avallone |
last post by:
MetaPro Systems Inc. Visual Studio Dot Net Tips & Tricks #3 – Direct
Access to
Your Outlook Address Book.
Project Type: VS.NET Windows Application
Code Behind: Visual Basic
I have a project...
|
by: hotelinfoline |
last post by:
I want to get outlook express (not microsoft outlook express) address
book address's in visual basic application. Please tell how I can get.
|
by: Alexander Szigetvary |
last post by:
Hi NG!
Is there a way to open the Outlook address book dialog (as in Outlook) using
C#? I am using Outlook 2003 (MS Outlook 11.0 Object Library).
In Outlook 2007 it can be done with...
|
by: Lpitt56 |
last post by:
I am running MS Access 2007 and I want to update an Outlook Address book from my Access Database. I started out by importing the Outlook Address Book as a linked table and it linked fine. I then...
|
by: Mike Miller |
last post by:
Hi,
Am wanting to send email with php and need to access the global
outlook address book. Are there any examples/tutorials on how to do
this?
M
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |