Home > Back-end >  How to minimize all opened items (appointment) using macro in Outlook
How to minimize all opened items (appointment) using macro in Outlook

Time:01-16

I am new in VBA macro programming, can anyone give an example vba macro script to minimize all opened items (appointments) in outlook.

I get example from https://www.slipstick.com/developer/outlook-vba-work-with-open-item-or-select-item/ and https://learn.microsoft.com/en-us/office/vba/api/outlook.application.activewindow but both example only minimize the currect active item window (not all minimize)

Any body can help me please?

Thank you

CodePudding user response:

The Outlook object model provides the WindowState property for that out of the box. It returns or sets the property with a constant in the OlWindowState enumeration specifying the window state of an explorer or inspector window.

Application.ActiveWindow.WindowState = olMinimized

If you need to minimize all Outlook windows (inspectors) you need to iterate over all inspectors in the Inspectors collection and set the property like shown above.

 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 
     myInspectors.Item(x).WindowState = olMinimized
   Next x  
 Else  
   MsgBox "No inspector windows are open."  
 End If 

To minimize Outlook windows you can also use Windows API functions. The ShowWindow function does the trick. You just need to pass the SW_MINIMIZE value which minimizes the specified window and activates the next top-level window in the Z order.

  • Related