+ Reply to Thread
Results 1 to 13 of 13

Minimize all excel windows except active worksheet

  1. #1
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Minimize all excel windows except active worksheet

    I would like code that would minimize (not hide!) all excel spreadsheet windows except for the active window, even if there is another window with the same workbook open.
    If I have open the following windows (whether already minimized or not) within excel:

    WorkbookA.xlsm:1
    WorkbookA.xlsm:2
    WorkbookB.xlsb:1
    WorkbookB.xlsb:2
    WorkbookC.xlsx

    and "WorkbookA.xlsm:2" is my active window, I want to be able to have all the windows except for "WorkbookA.xlsm:2" minimized, while leaving the "WorkbookA.xlsm:2" window untouched (please do not resize the window).
    Any hidden workbook windows should NOT be unhidden.

    Code I have looked up so far tend to either minimize all application windows (not just excel) or only minimize excel windows based on workbook names.

    Thank you in advance for any help.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Minimize all excel windows except active worksheet

    Something like this?
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Minimize all excel windows except active worksheet

    Hello Monimonika,

    You may also try,

    Please Login or Register  to view this content.
    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: Minimize all excel windows except active worksheet

    To CK76,
    I placed your code inside a module in Personal.XLSB in order to test it out.
    The windows minimize the way I want, but I keep getting a debug error on the line:
    Please Login or Register  to view this content.

    To Winon,
    How do I get your code to run? (Have also placed inside a module in Personal.XLSB.)

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Minimize all excel windows except active worksheet

    Hello Monimonika,

    As the Code indicates, it is not for a Standard Module. With the VBE open you should Click on ThisWorkbook in the list to the left of the screen, and Post the Code in there.

    Once you have done that, click on any Tab and then on Minimize, you should then see only that Tab Minimized with no other Tabs visible.

    Please try it, and if you still have any problems, let me know.

    Regards

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Minimize all excel windows except active worksheet

    The windows minimize the way I want, but I keep getting a debug error on the line:
    Can you insert below right after "For Each" line and see what comes up in immediate window when the error shows up? Along with exact error message.
    Please Login or Register  to view this content.
    I tested on my end without issue, and need a bit more detail.

  7. #7
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: Minimize all excel windows except active worksheet

    Hi Winon,

    From your description, it seems that the minimizing would be done automatically without me being able to control if I want to have it run or not in any particular instance. Sometimes I do want two or three windows to stay in view, not just only one window.
    To clarify, I plan to incorporate the code I want into some existing code that already opens and arranges windows for some of my workbooks. The problem is that if other windows are open, it messes up the window arranging. That's why I wanted to minimize all other windows except the one that I would be running my own code from.

    Thank you for your code, though. Much appreciated.

  8. #8
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: Minimize all excel windows except active worksheet

    CK76,

    I got this:

    Run-time error '1004':
    Unable to set the WindowState property of the Window class

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Minimize all excel windows except active worksheet

    Hello Monimonika,

    Thank you for the quick response!

    However,

    Sometimes I do want two or three windows to stay in view, not just only one window.
    I really don't know if anyone would be able to Program for your whims. LOL

    Please don't get mad at me, just ponder on it for a while!

    Regards.

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Minimize all excel windows except active worksheet

    Monimonika,

    What does "Debug.Print win.Caption" return? I suspect that, it's not standard Excel Window.
    You may need to add extra logic to skip this one. Or as temporary solution add "On Error Resume Next" (though I don't usually recommend this route unless you know that it won't cause issue else where in your code).

  11. #11
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: Minimize all excel windows except active worksheet

    CK76,

    Sorry, I did not have the Immediate Window displayed. Here's what prints out:

    2017 Tofu Box NJ Calendar (by Monika).xlsb:2
    2017 Tofu Box NJ Calendar (by Monika).xlsb:1
    PERSONAL.XLSB

    Is it maybe getting stuck on trying to minimize the PERSONAL.XLSB and failing? I tried assigning your code to a button so that I did not have VBA Editor open, but the results are the same.

  12. #12
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Minimize all excel windows except active worksheet

    Yes. PERSONAL.XLSB is the culprit. Just use another IF statement to avoid issue with it.

  13. #13
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: Minimize all excel windows except active worksheet

    Thank you so much, CK76!

    I added another AND to the IF condition to skip over the PERSONAL.XLSB.

    Please Login or Register  to view this content.
    YAY! Have a great weekend!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Disable close and minimize on split screen windows
    By ChristineJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2013, 04:12 PM
  2. minimize userform to windows taskbar
    By dulitul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2013, 06:27 PM
  3. need help to minimize the windows and allow other excel work books to open
    By Ignesh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2012, 08:56 AM
  4. open Excel with Macros active from windows schedule
    By bagullo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2011, 03:44 AM
  5. Replies: 6
    Last Post: 09-06-2005, 07:05 AM
  6. Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  7. Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  8. Replies: 2
    Last Post: 07-08-2005, 11:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1