Re: using SelectNamesDialog

Status
Not open for further replies.
R

RGFsdG9uX0w

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

> >

>

> "code_monkey_number_9" <code_monkey_number_9
> wrote in message news:F099BE2E-ABCA-4504-84C9-9121593DAF04@microsoft.com...
> > 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


>
 
K

Ken Slovak - [MVP - Outlook]

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.

"Dalton_L" <Dalton_L> wrote in message

news:F68B5CE8-2653-431E-BF8F-34FD7B6A3FC9@microsoft.com...
> 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.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
X Using Outlook 2013 and Outlook 365 Using Outlook 1
A Going to folder using shortcuts Using Outlook 3
A Outlook replies not using "delivered to" address in From Using Outlook 1
Terry Sullivan E-Mails Sent Using a Group Box Result in 70 Kickbacks Using Outlook 5
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
K Using Outlook 2016 to draw Using Outlook 1
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
N Disable Auto Read Receipts sent after using Advanced Find Using Outlook 4
G Outlook 2016 sync contacts directly between phone and computer using outlook 2016 Using Outlook 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
O Save attachments using hotkey without changing attributes Outlook VBA and Custom Forms 1
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
A Using or not using apostrophes in search terms has this changed? Using Outlook 0
O Office 365 using POP3 on both laptop and desktop Using Outlook 0
M Using field names to capture a data element Using Outlook 0
B Vba to monitor time to respond to emails using a shared mailbox Outlook VBA and Custom Forms 5
B Looking to get the Recipient email address (or even the "friendly name") from an email I am replying to using VBA Outlook VBA and Custom Forms 4
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
O Using .OST and .PST mail thru different providers Using Outlook 5
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
D Remove text in subject using VBA Outlook VBA and Custom Forms 4
P How to export voting results using VBA? Outlook VBA and Custom Forms 2
E Using the Like operator properly Outlook VBA and Custom Forms 1
R Using "check for duplicates" for existing contacts Using Outlook 2
S Find a cell value in excel using outlook vba Using Outlook 1
N Using email notification to update calendar events? Outlook VBA and Custom Forms 4
S Macro using .SendUsingAccount only works the first time, after starting Outlook Outlook VBA and Custom Forms 4
C Sync Calendars using WiFI Using Outlook 3
A Capturing Send Variables without using Application_ItemSend in ThisOutlookSession Outlook VBA and Custom Forms 8
L Using alpha numeric in email address Using Outlook 5
Sabastian Samuel HOW DO I FORWARD AN EMAIL WITH MACRO using an email that in the body of another email Outlook VBA and Custom Forms 3
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
D Print Attachments only in selected emails using a macro Outlook VBA and Custom Forms 3
B query outlook using vba Outlook VBA and Custom Forms 13
M Using conditional formatting on a shared calendar with categories Using Outlook 6
e_a_g_l_e_p_i A question about installing office 2013 Pro and using my .pst from office 2010 Using Outlook 12
A Forward Outlook Email by Filtering using Macro Rule Outlook VBA and Custom Forms 44
O How to paste website content using a specific font and removing URLs Using Outlook 2
P Replying to calendar item using VBA Outlook VBA and Custom Forms 4
N Export details to a excel spreadsheet using macros Using Outlook 0
R Toggle the Reading Pane using Keyboard Shortcut Using Outlook 0
S Error using AddressEntry.GetContact - need help Outlook VBA and Custom Forms 2
H Change Default Email Account Using VBA Outlook VBA and Custom Forms 5
S Outlook [Online - Office365] perfomance is getting affected when accessing the mails using Redemptio Using Outlook 1
M Using Outlook with Yahoo email Using Outlook 6
G Using Data From Combo Box in Appointment Body Outlook VBA and Custom Forms 6
U Using VBA to creat hyperlinks in an email Outlook VBA and Custom Forms 3
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
Similar threads


















































Top