Select Names Dialog Box

Status
Not open for further replies.
J

jo@jo.uk

Could someone help with the following?

I am using Access 2003 with outlook 2003 and all I need to do is open

outlook and for it to display the Select Names Dialog Box ( it would be nice

to open outlook if it was closed) no more than that. Hence I am now after

the code to go in the click event of the button.

Any examples of VBA code that will work within Access 2003 would be

appreciated
 
The Select Names dialog box is programmable starting from Outlook

2007. You can't display it in Outlook 2003.

http://msdn.microsoft.com/en-us/library/bb176400.aspx

--JP

On Feb 5, 3:52 pm, j...@jo.uk wrote:
> Could someone help with the following?

> I am using Access 2003 with outlook 2003 and all I need to do is open
> outlook and for it to display the Select Names Dialog Box ( it would be nice
> to open outlook if it was closed) no more than that. Hence I am now after
> the code to go in the click event of the button.

> Any examples of VBA code that will work  within Access 2003 would be
> appreciated
 
Thank you Jp for the info.

In view of your reply, I have seen code being used (VB) for the display of

the address book.

Have you used or knowledge of any outlook VBA address book code examples?

I will post a message in this group on this subject.

Thank you again
 
I don't doubt that you've seen code that displays the address book,

but Outlook doesn't provide any means of doing so prior to Outlook

2007. I have seen (and used) VBA code that manipulates contacts, but

not in the way you want. If you can show otherwise, I'd be glad to see

it.

--JP

On Feb 9, 12:32 pm, j...@jo.uk wrote:
> Thank you Jp for the info.
> In view of your reply, I have seen code being used (VB) for the display of
> the address book.
> Have you used or knowledge of any outlook VBA address book code examples?

> I will post a message in this group on this subject.

> Thank you again
 
Of course in the old days we used to use CDO.Session.AddressBook() to

display that dialog before the OOM exposed it.

"JP" <jp2112@earthlink.net> wrote in message

news:835aa6f7-4330-45a3-aa90-cf301fb69e93@c5g2000vbh.googlegroups.com...

I don't doubt that you've seen code that displays the address book,

but Outlook doesn't provide any means of doing so prior to Outlook

2007. I have seen (and used) VBA code that manipulates contacts, but

not in the way you want. If you can show otherwise, I'd be glad to see

it.

--JP

On Feb 9, 12:32 pm, j...@jo.uk wrote:
> Thank you Jp for the info.
> In view of your reply, I have seen code being used (VB) for the display of
> the address book.
> Have you used or knowledge of any outlook VBA address book code examples?

> I will post a message in this group on this subject.

> Thank you again
 
Hi, Ken

Is it possible to get the example working in the environment I need?

If so your help would be appreciated

Regards

Dave
 
That thread you referenced has code for that.

CDO is an optional installation for Office 2003 and earlier so you may not

have it installed, you have to check that. CDO also is subject to very

strict security, even stricter than the Outlook object model, so you also

have to be aware of that. Most of us stopped using CDO years ago because of

that, that's one of the reasons that Redemption (www.dimastr.com/redemption)

was created.

<jo@jo.uk> wrote in message

news:Or-dnVlPGYNHsunWnZ2dnUVZ7rqdnZ2d@giganews.com...
> Hi, Ken
> Is it possible to get the example working in the environment I need?
> If so your help would be appreciated
> Regards
> Dave
 
Hi, Ken

I am using the following code that basicly works, other than if outlook is

closed.

hence what code is required to open outlook if it is closed?

It also looks like .AddressBook has a number of options. Could you list or

point me to more information on the use of this command.

On Error GoTo err_Session_AddressBook

'MAPI Session

Dim objSession As MAPI.Session

Dim colCDORecips As Object

Set objSession = New MAPI.Session

'objSession.Logon "ProfileName", "outlook", False, False

objSession.Logon , , False, False

'show address book

Set colCDORecips = objSession.AddressBook(, _

"Pick Names", , , 1, _

"Recipients")

' release objects

objSession.Logoff

Set colCDORecips = Nothing

Set objSession = Nothing

err_Session_AddressBook:

If (Err = 91) Then ' MAPI dlg-related function that sets an object

MsgBox "No recipients selected"

Else

'MsgBox "Unrecoverable Error:" & Err

End If

Thank you

Dave
 
objSession.Logon , , False, False

That's what's called in CDO as a piggy-back logon, attaching to an existing

Outlook session. It would only work if Outlook is already running. An

alternative of specifying a CDO logon profile is usually not the best idea,

it ends up either leaking or creating profiles in your registry that you

don't really want.

Check for Outlook running and if it's not running then start it to avoid the

problem.

www.cdolive.com is the the Web site for CDO. The tips and tricks pages have

lots of code samples and you can download the CDO.HLP file from there which

explains all the arguments to everything in CDO.

<jo@jo.uk> wrote in message

news:x_ydnSnOUvQrBujWnZ2dnUVZ8v2dnZ2d@giganews.com...
> Hi, Ken
> I am using the following code that basicly works, other than if outlook
> is
> closed.
> hence what code is required to open outlook if it is closed?
> It also looks like .AddressBook has a number of options. Could you list
> or
> point me to more information on the use of this command.

> On Error GoTo err_Session_AddressBook
> 'MAPI Session
> Dim objSession As MAPI.Session
> Dim colCDORecips As Object

> Set objSession = New MAPI.Session
> 'objSession.Logon "ProfileName", "outlook", False, False
> objSession.Logon , , False, False
> 'show address book
> Set colCDORecips = objSession.AddressBook(, _
> "Pick Names", , , 1, _
> "Recipients")
> ' release objects
> objSession.Logoff

> Set colCDORecips = Nothing
> Set objSession = Nothing

> err_Session_AddressBook:
> If (Err = 91) Then ' MAPI dlg-related function that sets an object
> MsgBox "No recipients selected"
> Else
> 'MsgBox "Unrecoverable Error:" & Err
> End If

> Thank you

> Dave
 
Ken,

I have updated my code as below, it works how I need it to. However could

you have a look at it as I do not full understand you comment on the

objSession.Logon , , False, False.

also I did have a look at the www.cdolive.com site but the sites search

does not work and the copy of the CDO.HLP I can't read at the moment hence

I will have to revisit when I have a bit more time next week.

I take it that if I make a reference to CDO.dll and in my case have an

access database in a folder with the DLL the outlook code I am using will

work on any PC that uses the access programme?

Private Sub Command43_Click()

On Error GoTo err_Session_AddressBook

Dim objOL As Outlook.Application

Dim oOutlook As Object

Dim oMail As Object

Dim objSession As MAPI.Session

Dim colCDORecips As Object

On Error Resume Next

Set objOL = GetObject(, "Outlook.Application")

If Err.Number <> 0 Then

Set oOutlook = CreateObject("Outlook.Application")

Set oMail = oOutlook.CreateItem(olMailItem)

oMail.Display

End If

Set objSession = New MAPI.Session

objSession.Logon "ProfileName", "outlook", False, False

Set colCDORecips = objSession.AddressBook(, _

"Pick Names", , , 1, _

"Recipients")

' release objects

objSession.Logoff

Set colCDORecips = Nothing

Set objSession = Nothing

Set objOL = Nothing

Set oOutlook = Nothing

Set oMail = Nothing

err_Session_AddressBook:

If (Err = 91) Then ' MAPI dlg-related function that sets an object

MsgBox "No recipients selected"

Else

'MsgBox "Unrecoverable Error:" & Err

End If

End Sub

Thank you for you time and comments.
 
If you're starting Outlook, as I recommended, then you should go back to the

original CDO logon, but modified a little:

objSession.Logon "", "", False, False

If you want that code to run on other machines they will need to have CDO

installed on them. You are not allowed to deploy or distribute CDO yourself,

that's illegal. Plus each version of CDO is customized to a specific version

of Outlook.

We also do not recommend deploying Outlook VBA macro code. That's for

personal use or prototyping, not for distribution. For deployment you should

be coding a COM addin.

<jo@jo.uk> wrote in message

news:t82dndxeZo8kd-vWnZ2dnUVZ7sWdnZ2d@giganews.com...
> Ken,
> I have updated my code as below, it works how I need it to. However could
> you have a look at it as I do not full understand you comment on the
> objSession.Logon , , False, False.
> also I did have a look at the www.cdolive.com site but the sites search
> does not work and the copy of the CDO.HLP I can't read at the moment
> hence
> I will have to revisit when I have a bit more time next week.
> I take it that if I make a reference to CDO.dll and in my case have an
> access database in a folder with the DLL the outlook code I am using will
> work on any PC that uses the access programme?

> Private Sub Command43_Click()
> On Error GoTo err_Session_AddressBook

> Dim objOL As Outlook.Application
> Dim oOutlook As Object
> Dim oMail As Object
> Dim objSession As MAPI.Session
> Dim colCDORecips As Object

> On Error Resume Next
> Set objOL = GetObject(, "Outlook.Application")
> If Err.Number <> 0 Then
> Set oOutlook = CreateObject("Outlook.Application")
> Set oMail = oOutlook.CreateItem(olMailItem)
> oMail.Display

> End If

> Set objSession = New MAPI.Session
> objSession.Logon "ProfileName", "outlook", False, False

> Set colCDORecips = objSession.AddressBook(, _
> "Pick Names", , , 1, _
> "Recipients")
> ' release objects

> objSession.Logoff

> Set colCDORecips = Nothing
> Set objSession = Nothing
> Set objOL = Nothing
> Set oOutlook = Nothing
> Set oMail = Nothing

> err_Session_AddressBook:
> If (Err = 91) Then ' MAPI dlg-related function that sets an object
> MsgBox "No recipients selected"
> Else
> 'MsgBox "Unrecoverable Error:" & Err
> End If
> End Sub

> Thank you for you time and comments.
 
Thank you for the updated logon syntax.

All target PC have CDO installed so no problem with DLL now.

One final issue regarding the address book "show names from the".. drop

down.

How do I change the default location via code, eg at the moment its default

is "contacts" should I need its default to be say "outlook address book"
 
That's stored in the registry in the profile settings, it's all undocumented

binary and Unicode stuff there. It's something that Outlook reads on startup

only. You can't do much with that with a running session.

<jo@jo.uk> wrote in message

news:HeCdnTnsLJuoZefWnZ2dnUVZ8mCdnZ2d@giganews.com...
> Thank you for the updated logon syntax.
> All target PC have CDO installed so no problem with DLL now.
> One final issue regarding the address book "show names from the".. drop
> down.
> How do I change the default location via code, eg at the moment its
> default
> is "contacts" should I need its default to be say "outlook address book"
 
Thanks Ken. Some days, it seems like I open my mouth just to switch

feet.

--JP

On Feb 10, 1:21 pm, "
<kenslo...@mvps.org> wrote:
> Of course in the old days we used to use CDO.Session.AddressBook() to
> display that dialog before the OOM exposed it.

> >

> http://www.slovaktech.com

> "JP" <jp2...@earthlink.net> wrote in message

> news:835aa6f7-4330-45a3-aa90-cf301fb69e93@c5g2000vbh.googlegroups.com...
> I don't doubt that you've seen code that displays the address book,
> but Outlook doesn't provide any means of doing so prior to Outlook
> 2007. I have seen (and used) VBA code that manipulates contacts, but
> not in the way you want. If you can show otherwise, I'd be glad to see
> it.
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Contacts as default in Select Names dialog Using Outlook 1
R Add 'Company' to Select Names Form Using Outlook 1
C Outlook 2007 Select Names Default columns Using Outlook 3
I Address book contacts not listed in "Select Names:Contacts" window Using Outlook 2
M Search message, then (1) Jump to folder & (2) Select message that you searched for Outlook VBA and Custom Forms 2
R Select Multiple Graphic Objects Using Outlook 0
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
D VBA code to select a signature from the signatures list Outlook VBA and Custom Forms 3
C must select message to trigger safe list Using Outlook 3
O VBA Cases with Listbox - Can you use Multi-Select? Outlook VBA and Custom Forms 4
E Asking user to select multiple options in a list in an email Outlook VBA and Custom Forms 0
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
B Select / activate first email item in the searched query Using Outlook 1
A Multi-select Listbox Outlook VBA and Custom Forms 6
H Select Specific Account When Sending Email, Based on Current Folder Outlook VBA and Custom Forms 1
S Display PF contact folder items to select contact to link to appointment Outlook VBA and Custom Forms 1
N Auto-complete - block select emails Using Outlook 3
N Select Appointment subject line from combobox or list Outlook VBA and Custom Forms 1
G How to Copy Multi Select Listbox Data to Appointment Outlook VBA and Custom Forms 3
N Select a folder in a user account Outlook VBA and Custom Forms 2
Diane Poremsky Select from a List of Subjects before Sending a Message Using Outlook 0
Diane Poremsky Select Multiple Calendars in Outlook Using Outlook 0
P Select image in contact notes field and save as jpg Outlook VBA and Custom Forms 6
oliv- How to select an mailitem in explorer with "show as conversation" Outlook VBA and Custom Forms 8
N Select Existing BCM Business Contact in C# application Using Outlook 0
nathandavies Creating a Select Case for a directory of folders Outlook VBA and Custom Forms 1
B What is the best way to use Outlook address book to select customer and then open Excel Outlook VBA and Custom Forms 22
R Can BCM monitor and select specific emails and use content info to update the client's record? BCM (Business Contact Manager) 1
R Cannot select iCloud calendar Using Outlook 5
H Select one of Contact-Mailadesses to Export > Excel or Winword Outlook VBA and Custom Forms 2
G Select Outlook account for BCM? BCM (Business Contact Manager) 2
Z Manual archive of select folders Using Outlook 1
R How to modify Outlook Select Rooms form columns Using Outlook 1
Z bulk add categories / with fixed colours / select multiple categories on a not Using Outlook 1
C Outlook editing won't select just one word Using Outlook 1
Y Outlook 2010 Select and reply to multiple messages at one time Using Outlook 0
Y Outlook 2010 Select and reply to multiple messages at one time Using Outlook 2
S Outlook 2007 caendar hangs when I select today's day BCM (Business Contact Manager) 4
S Outlook Email Help: Select custom voting button options VBA Outlook VBA and Custom Forms 1
W Outlook Coding - Select different email adresses to send from Outlook VBA and Custom Forms 5
A Select the position of an attached file in a HTML mailitem Outlook VBA and Custom Forms 1
H Select/Unselect items in ActiveExplorer by code? Outlook VBA and Custom Forms 2
M How to programmatically select a outlook search folder? Outlook VBA and Custom Forms 1
M Select Alternate profile Outlook VBA and Custom Forms 1
S Event for email message select Outlook VBA and Custom Forms 1
L RE: Select Users in Shared Database BCM (Business Contact Manager) 1
R select folder as addressbook Outlook VBA and Custom Forms 1
S Select a folder in Outlook (in code) Outlook VBA and Custom Forms 2
N Trouble with server names Using Outlook 1

Similar threads

Back
Top