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
 
J

JP

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
 
J

jo@jo.uk

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
 
J

JP

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
 
K

Ken Slovak - [MVP - Outlook]

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
 
J

jo@jo.uk

Hi, Ken

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

If so your help would be appreciated

Regards

Dave
 
K

Ken Slovak - [MVP - Outlook]

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
 
J

jo@jo.uk

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
 
K

Ken Slovak - [MVP - Outlook]

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
 
J

jo@jo.uk

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.
 
K

Ken Slovak - [MVP - Outlook]

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.
 
J

jo@jo.uk

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"
 
K

Ken Slovak - [MVP - Outlook]

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"
 
J

JP

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.
Thread starter Similar threads 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
Z "Select Names: Contacts" Menu displays contacts in different ways Using Outlook 6
G When I click 'To' to 'select names' there is no info Using Outlook 4
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 New Slipstick.com Articles 0
Diane Poremsky Select Multiple Calendars in Outlook New Slipstick.com Articles 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
D How to select different account when sending emails from Outlook 2003 Using Outlook 3
E Outlook 2010 calendar print - select begin-end weeks for month print but Preview and print show ful Using Outlook 2
R Select contacts and print labels for selected contacts from complete contact list in Outlook. Using Outlook 1
F Why do messages only arrive when I select the server's folder? Using Outlook 3
P Sharing Outlook contacts so users can select as an address book for email. Using Outlook 1
B Do not allow / Show to select "Tentative" option in Responce Using Outlook 1
H Exchange Server 2007 strips messages when clients select add item in a new Message Using Outlook 10
R Cannot select items from Outlook 2007 Menu bars Using Outlook 1
D Outlook 2010 crashes when I select new message, reply, forward or send as attachment Using Outlook 3
M Not able to select my contacts list for my address book Using Outlook 7
L Rule to select incoming messages by contact category Using Outlook 11
C Select folder to file send emails Using Outlook 1
G MS Exchange ActiveSync 2007 Denying Select Devices Exchange Server Administration 2
D Select categories to print Using Outlook 1
C Error when trying to select the Email Auto link option Using Outlook 2
N Not able to select the details of a head office synced contact Exchange Server Administration 4
G Select DAG for Express full backup ofr copy backups Exchange Server Administration 1
S Outlook 2003: For select messages only, would like replies automatically sent to 2 separate addresses. Using Outlook 4
Similar threads


















































Top