+ Reply to Thread
Results 1 to 2 of 2

Closing Workbooks...

  1. #1
    Forum Contributor
    Join Date
    02-27-2007
    Posts
    156

    Question Closing Workbooks...

    I use the following to open an additional workbook when I start my Excel session.

    Please Login or Register  to view this content.
    Now I want to close it as well... How could I go about making sure this workbook that gets opened is also closed and of course do the error checking that if it wasn't opened because it didn't exist that there wouldn't be anything to close.... Any help is appreciated.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: Closing Workbooks...

    You've assigned a variable to the workbook. So save, if necessary, and close that in the Workbook Before Close event handler. Use "On Error Resume Next" to trap the error if the workbook wasn't opened at the outset. If you didn't open it, you managed without it, didn't need it and there's nothing to close ... so you can just ignore the error.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. Macro to autoclose hidden workbooks is closing all active workbooks
    By tlchavez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2013, 06:38 PM
  2. Closing Workbooks without saving
    By bruce71101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-09-2011, 09:56 PM
  3. Closing workbooks
    By deeppurple247 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2007, 05:01 PM
  4. Closing / Opening Workbooks
    By AMK4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-01-2007, 05:04 PM
  5. Closing Workbooks
    By bodhisatvaofboogie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2006, 09:00 AM

Tags for this Thread

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