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