A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

using SelectNamesDialog



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 18th 08, 07:27 PM posted to microsoft.public.outlook.program_vba
code_monkey_number_9
external usenet poster
 
Posts: 1
Default using SelectNamesDialog

question about using the SelectNamesDialog when automating Outlook 2007 from
Access 2007: the MSDN Office Developer Center remarks that, for the Display
method, "When displaying the Select Names dialog box, Display uses the
previous location and size (indicated by the top, left, width, and height) of
the dialog box."

For me this means that when I display the box, it is consistently hidden
behind one or more other open windows. When I call the dialog from my access
form, I have to click on the Outlook application (on the start bar) to
'activate' outlook for the dialog to appear.

Is there a way to set the dialog's position and/ or focus?

Here's how I'm calling the dialog:

Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olDialog As SelectNamesDialog
Dim olAddressList As AddressList
Dim olRecipient As Outlook.Recipient
Dim strTo As String
Dim x As Integer

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")

Set olDialog = olNS.GetSelectNamesDialog
Set olAddressList = olNS.GetGlobalAddressList

With olDialog
.InitialAddressList = olAddressList
.SetDefaultDisplayMode olDefaultMeeting
If .Display Then

For Each olRecipient In .Recipients
x = x + 1
strTo = strTo & .Recipients(x) & "; "
Next
End If
End With

Me.Text12 = strTo

Set olApp = Nothing
Set olNS = Nothing
Set olDialog = Nothing
Set olAddressList = Nothing
Ads
  #2  
Old September 18th 08, 07:38 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default using SelectNamesDialog

The dialog is modal to Outlook, not to all open windows. That's why you have
to select Outlook to bring it to the front.

You would have to get the window handle of that dialog using the
FindWindow() Win32 API method. Then you'd have to set it to a topmost window
if you want it in front of all other windows most likely using the
SetWindowLong() Win32 API call.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"code_monkey_number_9"
wrote in message ...
question about using the SelectNamesDialog when automating Outlook 2007
from
Access 2007: the MSDN Office Developer Center remarks that, for the
Display
method, "When displaying the Select Names dialog box, Display uses the
previous location and size (indicated by the top, left, width, and height)
of
the dialog box."

For me this means that when I display the box, it is consistently hidden
behind one or more other open windows. When I call the dialog from my
access
form, I have to click on the Outlook application (on the start bar) to
'activate' outlook for the dialog to appear.

Is there a way to set the dialog's position and/ or focus?

Here's how I'm calling the dialog:

Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olDialog As SelectNamesDialog
Dim olAddressList As AddressList
Dim olRecipient As Outlook.Recipient
Dim strTo As String
Dim x As Integer

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")

Set olDialog = olNS.GetSelectNamesDialog
Set olAddressList = olNS.GetGlobalAddressList

With olDialog
.InitialAddressList = olAddressList
.SetDefaultDisplayMode olDefaultMeeting
If .Display Then

For Each olRecipient In .Recipients
x = x + 1
strTo = strTo & .Recipients(x) & "; "
Next
End If
End With

Me.Text12 = strTo

Set olApp = Nothing
Set olNS = Nothing
Set olDialog = Nothing
Set olAddressList = Nothing


  #3  
Old September 18th 08, 08:13 PM posted to microsoft.public.outlook.program_vba
code_monkey_number_9[_2_]
external usenet poster
 
Posts: 1
Default using SelectNamesDialog

Wow, a celebrity answer! Thanks, Ken!

"Ken Slovak - [MVP - Outlook]" wrote:

The dialog is modal to Outlook, not to all open windows. That's why you have
to select Outlook to bring it to the front.

You would have to get the window handle of that dialog using the
FindWindow() Win32 API method. Then you'd have to set it to a topmost window
if you want it in front of all other windows most likely using the
SetWindowLong() Win32 API call.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"code_monkey_number_9"
wrote in message ...
question about using the SelectNamesDialog when automating Outlook 2007
from
Access 2007: the MSDN Office Developer Center remarks that, for the
Display
method, "When displaying the Select Names dialog box, Display uses the
previous location and size (indicated by the top, left, width, and height)
of
the dialog box."

For me this means that when I display the box, it is consistently hidden
behind one or more other open windows. When I call the dialog from my
access
form, I have to click on the Outlook application (on the start bar) to
'activate' outlook for the dialog to appear.

Is there a way to set the dialog's position and/ or focus?

Here's how I'm calling the dialog:

Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olDialog As SelectNamesDialog
Dim olAddressList As AddressList
Dim olRecipient As Outlook.Recipient
Dim strTo As String
Dim x As Integer

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")

Set olDialog = olNS.GetSelectNamesDialog
Set olAddressList = olNS.GetGlobalAddressList

With olDialog
.InitialAddressList = olAddressList
.SetDefaultDisplayMode olDefaultMeeting
If .Display Then

For Each olRecipient In .Recipients
x = x + 1
strTo = strTo & .Recipients(x) & "; "
Next
End If
End With

Me.Text12 = strTo

Set olApp = Nothing
Set olNS = Nothing
Set olDialog = Nothing
Set olAddressList = Nothing



  #4  
Old March 14th 09, 05:44 PM posted to microsoft.public.outlook.program_vba
Dalton_L
external usenet poster
 
Posts: 1
Default using SelectNamesDialog

Thank you Ken. I am looking for a solution also, and I see where your answer
is heading. What I am stuck on is how to execute the API functions you
suggested in the Access VBA module. Since the SelectAnmes dialog is modal,
the Access code exectuion stops at the call to .Display.

I'm sure I am overlooking something fairly simple here.

"Ken Slovak - [MVP - Outlook]" wrote:

The dialog is modal to Outlook, not to all open windows. That's why you have
to select Outlook to bring it to the front.

You would have to get the window handle of that dialog using the
FindWindow() Win32 API method. Then you'd have to set it to a topmost window
if you want it in front of all other windows most likely using the
SetWindowLong() Win32 API call.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"code_monkey_number_9"
wrote in message ...
question about using the SelectNamesDialog when automating Outlook 2007
from
Access 2007: the MSDN Office Developer Center remarks that, for the
Display
method, "When displaying the Select Names dialog box, Display uses the
previous location and size (indicated by the top, left, width, and height)
of
the dialog box."

For me this means that when I display the box, it is consistently hidden
behind one or more other open windows. When I call the dialog from my
access
form, I have to click on the Outlook application (on the start bar) to
'activate' outlook for the dialog to appear.

Is there a way to set the dialog's position and/ or focus?

Here's how I'm calling the dialog:

Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olDialog As SelectNamesDialog
Dim olAddressList As AddressList
Dim olRecipient As Outlook.Recipient
Dim strTo As String
Dim x As Integer

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")

Set olDialog = olNS.GetSelectNamesDialog
Set olAddressList = olNS.GetGlobalAddressList

With olDialog
.InitialAddressList = olAddressList
.SetDefaultDisplayMode olDefaultMeeting
If .Display Then

For Each olRecipient In .Recipients
x = x + 1
strTo = strTo & .Recipients(x) & "; "
Next
End If
End With

Me.Text12 = strTo

Set olApp = Nothing
Set olNS = Nothing
Set olDialog = Nothing
Set olAddressList = Nothing



  #5  
Old March 16th 09, 01:50 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default using SelectNamesDialog

Since the dialog is modal to Outlook and isn't present in the collection of
windows before you call Display, which displays the dialog modally, you can
try getting the main Outlook window first using FindWindow(), then making
that the top window and giving it focus before you call Display.

The main Outlook window (Explorer) has a class name of "rctrl_renwnd32",
the caption will vary depending on what folder you're in, but you can get
that from ActiveExplorer.Caption.

Once you have that information you have enough to use SetWindowLong() or
SetWindowPos() to set the Outlook window on top, then the dialog should
display on top of that window.

To make a window display at the top of the z-order you can use the HWND_TOP
argument, or to make it the topmost of all windows you can use HWND_TOPMOST.
You can get information on declaring and calling those Win32 API functions
from the MSDN library.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Dalton_L" wrote in message
...
Thank you Ken. I am looking for a solution also, and I see where your
answer
is heading. What I am stuck on is how to execute the API functions you
suggested in the Access VBA module. Since the SelectAnmes dialog is modal,
the Access code exectuion stops at the call to .Display.

I'm sure I am overlooking something fairly simple here.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.