+ Reply to Thread
Results 1 to 3 of 3

VBA to close workbook windows

  1. #1
    Registered User
    Join Date
    11-07-2019
    Location
    Lithuania
    MS-Off Ver
    Office 2013
    Posts
    52

    VBA to close workbook windows

    Hello,
    I have a workbook with 2 opened windows, using the View > Window > New Window buttons. The code i need is that if one of windows are closed the other one would be closed as well. Any help or tips?

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: VBA to close workbook windows

    To close a workbook based on an event in that workbook requires that you use a macro in another workbook: this should go into a standard codemodule in your Personal.xlsb

    Please Login or Register  to view this content.

    Then:

    1) Copy this code.
    2) Open the VBE (press Alt-F11)
    3) Select your workbook in the project explorer
    4) Double-click the ThisWorkbook object
    5) Paste the code into the window that appears.
    6) Save the file as a macro-enabled .xlsm file.

    Change False to True in the CloseMe macro if you want to save changes before closing the workbook

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    11-07-2019
    Location
    Lithuania
    MS-Off Ver
    Office 2013
    Posts
    52

    Re: VBA to close workbook windows

    Works great. Thank you for your help.

+ 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. Copy from first workbook, close open new workbook paste close
    By johncarr1952 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 08-04-2021, 08:50 AM
  2. [SOLVED] Macro to close two open windows of the same workbook ?
    By karmapala in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 08-28-2019, 08:22 AM
  3. Windows task scheduler to automatically open(then close) an excel workbook
    By aprildu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2018, 11:49 PM
  4. Replies: 2
    Last Post: 11-05-2017, 01:18 PM
  5. Windows().close error 9
    By CJFugate in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2016, 08:27 PM
  6. Close all Windows?
    By nbaj2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2006, 09:59 AM

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