Markowitz Markowitz - 2 years ago 117 Question

Loop for all outlook inspectors

Lets say I have opened 3 outlook inspector.

How to loop for 3 outlook inspector?

So, I need a code like following;

For Each i In All.Outlook.Inspectors

Next i

Answer Source

The following code uses the Inspectors property and the Count property and Item method of the Inspectors object to display the captions of all inspector windows.

Dim myInspectors As Outlook.Inspectors  
Dim x as Integer  
Dim iCount As Integer 
Set myInspectors = Application.Inspectors  
iCount = Application.Inspectors.Count  
If iCount > 0 Then  
  For x = 1 To iCount
    MsgBox myInspectors.Item(x).Caption  
  Next x  
  MsgBox "No inspector windows are open."  
End If 

You may find the Getting Started with VBA in Outlook 2010 article helpful.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download