PDA

View Full Version : Search Outlook from Excel & display results in Outlook



viktoryeung
11-22-2011, 03:07 PM
Hello,
I want to initiate an Outlook search, by clicking an Excel userform label that has a search value.
Search results displayed in Outlook. Not importing any data to Excel.
Can you help? : pray2:


Private Sub LB_EmailAddress_Click()
'Clicking this Excel UF label would initiate an Outlook search for the label value
Dim EmailAddress As String

EmailAddress = Me.LB_EmailAddress.Value
'1 activate Outlook
'2 enter EmailAddress into Outlook search bar
'3 execute search

End Sub

JP2112
12-02-2011, 12:30 PM
You could check out the AdvancedSearch Method (search for it in Outlook's VBA help). However that will not directly display the results, just return them to your VBA program.

Also, I don't believe you can programmatically invoke Outlook's Advanced Find dialog (I would love to hear otherwise):

From http://support.microsoft.com/kb/146636:



Q: How can I programmatically search for items and folders based on the contents of a field?

A: You cannot programmatically use the Find or Advanced Find features in Outlook, but you can use the Find method in the Outlook object model to retrieve a single item based on the contents of one or more fields. You can also use the Restrict method to retrieve a set of items that match certain criteria.


You're better off launching Outlook, doing your search then displaying results in Excel using a userform.