GetSelectNamesDialog Pre-fill search box

Status
Not open for further replies.

AaronSt

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Diane or other experts out there, Is there a way to fill-in the left-most search box of the GetSelectNamesDialog through a VBA method or MAPI property or other?

I would like to add a convenience to the user for the case where the GetSelectNamesDialog pops up: I see in Outlook SelectName dialog that it will fill in the "search" name to filter the list. I would like to do this with the user last name. Can I set a property of the dialog or send a string to it as the initial search? How do they do it in Outlook? See picture.
947915


Thank you in advance,
Aaron
 
Thank you Michael. I'm glad I brought this to another forum. The solution looks quite complex but I understand what it is trying to do and why. Too bad that functionality isn't part of the selectnamesdialog already.

I tried running the code and ran into this error on the call of SetTimer: "Invalid use of AddressOf operator.". I am using 64-bit windows. Does that matter? Have you been able to get past this one somehow?
 
Figured it out... All the code in Michael's link needs to be in a new module (as stated in the page). I had it in "ThisWorkbook".
 
Still not working fully for me. It appears the timer is not firing until after the modal GetSelectNamesDialog is closed. After, the timer fires and the rest of the process continues. Since the GetSelectNamesDialog is closed, however, it does not find the right window and exits out. I confirmed that the functionality works however by leaving another SelectNamesDialog open in Outlook that the macro found and pre-filled successfully. What am I missing to get the timer to fire while the SelectNamesDialog is open?
 
then most likely you haven't copied the code as it is but do call Display before calling SetTimer.
 
I think it's because the code was intended for Outlook and I am running it from Excel. As a result, the code stops waiting for the modal outlook application dialog to close before it can continue, or at least that is my guess. I copied the code as is.
 
then most likely you haven't copied the code as it is but do call Display before calling SetTimer.

Michael Bauer: One thing that's stopping the code working as-is is that 'Private m_PrefillWithThis As String' has been declared in part 1, but in part 2 the name of the variable has been changed to 'm_FindThisName' so it doesn't find it. I can confirm that the code works properly in Outlook 2013 once the variable name is resolved. Possibly it would still work without correction if user does not set Option Explicit, I don't know. Also is the code yours? I like to give credit where possible. If so many thanks! Robin
 
Thanks Robin, I´ve corrected the sample. And yes, it´s my code. If you want to share it, please add a link to the page you´ve got it from.
 
Thanks Robin, I´ve corrected the sample. And yes, it´s my code. If you want to share it, please add a link to the page you´ve got it from.

Thanks Michael. I probably wont share it but have added the details to my copy of the code in case it does ever get shared. Also if you or anyone else is interested I have added code to click the 'more columns' and 'go' buttons in the dialog as well as prefilling the box:

Add Declaration:
Public Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long

Modify Prefill... sub (changed dimensioning a bit, added a bit):
Private Sub PrefillSelectNames()
Dim hndDialog As Long
Dim hndTextBox As Long
Dim hndButton As Long
Dim OK As Boolean

hndDialog = GetDesktopWindowA
hndDialog = FindChildWindowText(hndDialog, m_DialogCaption)

If hndDialog Then
hndTextBox = FindChildClassName(hndDialog, "RichEdit20W")
If hndTextBox Then
SetText hndTextBox, m_PrefillWithThis
OK = True
'******************* Added this bit...

'Clicks 'More Columns'
hndButton = FindWindowEx(hndDialog, ByVal 0&, "Button", "Mo&re columns")
If hndButton <> 0 Then
Call SendMessageByStringA(hndButton, LMouseButton, 0, 0)
End If
'Clicks 'Go'
hndButton = FindWindowEx(hndDialog, ByVal 0&, "Button", "&Go")
If hndButton <> 0 Then
Call SendMessageByStringA(hndButton, LMouseButton, 0, 0)
End If

'********************
End If
End If

If OK = False Then
MsgBox "window not found"
End If
End Sub
 
Sorry forgot, also have to declare:
Public Const LMouseButton = &HF5&
 
Status
Not open for further replies.

Similar threads

Back
Top