Wednesday, January 14, 2009

Minimize all open workbooks in Excel

I just had to share this. I spent an hour searching the interwebs looking for a simple VBA code to minimize all of the open workbooks in Excel. It seems like it should be really easy and simple to find, but it wasn't. Finally, after borrowing some code from excel.tips.net, and tweaking it slightly, I came up with this:

Sub Minimize_All()
    Application.ScreenUpdating = False
    Dim wkb As Workbook

    For Each wkb In Workbooks
        If Windows(wkb.Name).Visible Then _
          ActiveWindow.WindowState = xlMinimized
    Next
    Application.ScreenUpdating = True
End Sub

And it works perfectly! I created myself a little icon and now all is right with the world; until I find something else to fix.

--
~Angela Benton

2 comments:

Magnolia2020 said...

That's cool !

Can you write a VBA code that will:

1) Minimize all the Excel workbooks except for the one you are working on.
2) Create a new window for the opened workbook and arrange the windows horizontally.
3) Switch "View" to Full Screen.

All in one click !!

Angela said...

This should work for you:

Sub Minimize_Background_New_Window_Full_Screen()
Application.ScreenUpdating = False

Dim Wb As Workbook
Dim AWb As String
AWb = ActiveWorkbook.Name

For Each Wb In Workbooks
If Wb.Name <> AWb Then
Windows(2).WindowState = xlMinimized
End If
Next Wb

ActiveWindow.NewWindow
ActiveWorkbook.Windows.Arrange ArrangeStyle:=xlHorizontal
Application.DisplayFullScreen = True

Application.ScreenUpdating = True
End Sub