Markowitz Markowitz - 7 months ago 27
Vb.net 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 vb.net code like following;

For Each i In All.Outlook.Inspectors

Next i

Answer

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  
Else  
  MsgBox "No inspector windows are open."  
End If 

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

Comments