AdvancedSearchComplete

M

Marc Bertrand

I am trying to search a .PST file for certain words. If
I step through the application, I can see that
results.count has a value of 140, which is great! My
problem is, I can't get the AdvancedSearchComplete event
to fire up. So, of course, I figure I am doing something
wrong. I start researching, and see a code snipper that
Sue Mosher posted. I cut and paste it into Outlook's
Visual Basic Editor, fire it up, and get the same
results! To simplify the matter, I searched my
inbox....but the idea is the same. Why won't the
AdvancedSearchComplete event fire?

I don't think the issue is the code....but just in case..

Code below:

Public Sub cmdGetTasks_Click()
Dim strScope As String
Dim olSearch As Search
Dim myResults As Results
strScope = "'Inbox'"
Set olSearch = Application.AdvancedSearch(strScope, ,
True)
Do While olSearch.Tag = ""
DoEvents
Loop
' work with results
If olSearch.Tag = "complete" Then
Set myResults = SearchObject.Results
MsgBox "The number of objects found in the search
is: " & myResults.Count
End If
End Sub

Private Sub Application_AdvancedSearchComplete(ByVal
SearchObject As Search)
'Get Search object's results collection.
SearchObject.Tag = "complete"
End Sub
 
S

Sue Mosher [MVP]

Where did you put the Application_AdvancedSearchComplete event handler? It needs to be in the ThisOutlookSession module.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
M

Marc Bertrand

Hi Sue....

Thank you so much for the reply.

I have to admit, I didn't have the
Application_AdvancedSearchComplete in the
ThisOutlookSession module. I place it there now, but my
results are the same. This is so odd......
-----Original Message-----
Where did you put the Application_AdvancedSearchComplete
event handler? It needs to be in the ThisOutlookSession
module.
 
M

Marc Bertrand

Hi Sue!!

Thanks for your help! I fired up Outlook today, and
wanted to take a second (or is it third? Fourth?) look at
this problem. I tried running the macro in exactly the
same way I did yesterday, with no changes, and it worked!!

I have one last question, if anyone know the answer: I
see there is a IsSynchronous property for the Search. Is
there any way to make that True? It is currently false, an
it seems to be read only. I would prefer to search
synchronously, if possible......Any ideas?

-----Original Message-----
Where did you put the Application_AdvancedSearchComplete
event handler? It needs to be in the ThisOutlookSession
module.
 
S

Sue Mosher [MVP]

AdvancedSearch is asynchronous only.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top