Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to count advanced searches in outlook 2010

Status
Not open for further replies.

Cpreston

MIS
Mar 4, 2015
987
GB
Hi

I want to be able to do an advance search in Outlook and be able top count the number of emails found in that search.

To do the search I am going into Search Tools\ Advance find and then setting the criteria. This brings up the result in a separate window which is fine.

I then want to be able to have a count of this active window. I found some code which counts selected emails, but because the search result comes in a separate active window , whenever I go to the macro it loses the active window so I cannot count the emails.

I have tried adding the macro into the toolbars but cannot get it to work with the advanced search window because it loses it being active as soon as I click on any other menu.

Is there a way I can add the macro into the advanced file results box? macro is as below and works fine on normal folders

Sub CountSelectedItems()
Dim objSelection As Outlook.Selection
Dim Result As Integer
Set objSelection = Application.ActiveExplorer.Selection
Result = MsgBox("Number of selected items: " & _
objSelection.Count, vbInformation, "Selected Items")
End Sub


Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top