+ Reply to Thread
Results 1 to 5 of 5

Macro to autoclose hidden workbooks is closing all active workbooks

  1. #1
    Registered User
    Join Date
    03-13-2013
    Location
    Albuquerque, NM, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Macro to autoclose hidden workbooks is closing all active workbooks

    Good afternoon. I have a macro set to auto-open several linked workbooks for a data reference workbook and these sheets are hidden. When the user closes the data reference workbook there is a macro that runs to auto close the hidden workbooks. This works great, unless the user has other workbooks open at that same time. If the user has other workbooks open then it will close all the active workbooks and not ask for any changes to be saved. The next time the user goes to open the other active workbooks it gives them the auto recover option. Is there any way to keep the macro from closing the workbooks that are not listed in the macro (linked to the data reference workbook)?

    Sincerely,

    Tammy

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Macro to autoclose hidden workbooks is closing all active workbooks

    The auto_Open obviously opens specific workbooks whereas the auto_close shuts down everything... use the list from the open macro to explicitly close the related workbooks only..
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    03-13-2013
    Location
    Albuquerque, NM, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to autoclose hidden workbooks is closing all active workbooks

    Hi Andy. Thank you for that reply but we do have the specific files listed in the Auto Close. I am copying it here so you can see what we have.


    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    On Error Resume Next
    Workbooks("GDWL UNITS PRODUCED CURRENT YEAR.xlsx").Close SaveChanges:=False
    Workbooks("GDWL UNITS SOLD CURRENT YEAR.xlsx").Close SaveChanges:=False
    Workbooks("GDWL Sales Current Year.xlsx").Close SaveChanges:=False
    Workbooks("GDWL UNITS PRODUCED HISTORY YEAR.xlsx").Close SaveChanges:=False
    Workbooks("GDWL UNITS SOLD HISTORY YEAR.xlsx").Close SaveChanges:=False
    Workbooks("GDWL Sales History Year.xlsx").Close SaveChanges:=False
    Workbooks("GDWL DONORS_TRANSACTIONS_CURRENT_YEAR.xlsx").Close SaveChanges:=False
    Workbooks("GDWL DONORS_TRANSACTIONS_HISTORY_YEARS.xlsx").Close SaveChanges:=False
    Workbooks("GDWL Budget Numbers Current and History Years.xlsx").Close SaveChanges:=False
    Workbooks("GDWL Donations Current Year.xlsx").Close SaveChanges:=False
    Workbooks("GDWL UNITS PULLED CURRENT YEAR.xlsx").Close SaveChanges:=False
    On Error GoTo 0
    Me.Close SaveChanges:=False

    End Sub


    The worksheet that these are linked to is a read only file as we don't want the users to make any changes to the worksheet.

    Thank you again,
    Tammy

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Macro to autoclose hidden workbooks is closing all active workbooks

    In that case Tammy, I'm a bit stumped as to why it's closing down the additional workbooks. Unless maybe they have the same name as one targeted for closure ???

  5. #5
    Registered User
    Join Date
    03-13-2013
    Location
    Albuquerque, NM, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to autoclose hidden workbooks is closing all active workbooks

    They shouldn't have the same name as any of the ones listed or the one they are linked to. I have encountered this problem on a workstation and their server.

    Thanks for trying to help. :-)

    Tammy

+ 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. [SOLVED] Open Multiple Workbooks, Record names, Copy paste to Active Workbook, Close the Workbooks
    By vba_madness in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 06:09 AM
  2. Replies: 0
    Last Post: 08-07-2012, 02:19 PM
  3. Replies: 2
    Last Post: 06-20-2012, 09:08 PM
  4. Macro to copy column from multiple workbooks and transpose in active book
    By kishen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2011, 05:48 AM
  5. Replies: 5
    Last Post: 05-05-2005, 11:06 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