+ Reply to Thread
Results 1 to 4 of 4

Close workbook and create a new one

  1. #1
    Registered User
    Join Date
    01-17-2014
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    2

    Close workbook and create a new one

    Hi,

    I would need help regarding the attached test file. When I try to close
    the workbook by using the "close workbook "button on the userform, a message
    box appears to create a new empty workbook. If I click "Yes", the active workbook
    closes but nothing else happens. If I close the form and simple close the workbook
    manually by clicking the "X" in the corner, everything works fine. I think I know the
    reason of the problem but I don't know the solution. I hope somebody has a good idea.

    Thanks in advance for your help!

    (The ZIP file contains a video about the problem.)

    Laszlo
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    12-19-2012
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    135

    Re: Close workbook and create a new one

    Hi

    Not sure why it does not work but have found a different way to do it. Let me know if its ok for you.

    Remove the "BeforeClose" event.

    Then change your code "CommandButton6_Click" to

    Please Login or Register  to view this content.
    Regards
    Steve
    Last edited by Steve@Rugby; 01-17-2014 at 06:15 AM.

  3. #3
    Forum Contributor
    Join Date
    12-19-2012
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    135

    Re: Close workbook and create a new one

    If you wanted to also close the application if not creating new workbook use this version

    Please Login or Register  to view this content.
    Regards
    Steve

  4. #4
    Registered User
    Join Date
    01-17-2014
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Close workbook and create a new one

    Hi Steve,

    Thanks for you effort! It works fine but I need the same process when I simple close the workbook by clicking the "X" in the corner.
    This action will call the "Before_Close" event so if I remove it, nothing will happen.

    Regards,
    Laszlo

+ 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] Closing a Workbook from another workbook: Workbooks.close error: Subscript out of range
    By Coreyusa in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-14-2013, 06:45 PM
  2. Create a Command Button to "Save As" and "Close" an Excel Workbook
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-26-2013, 05:38 PM
  3. Disable close workbook but still force users to close thru command button
    By rathig in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2013, 07:29 AM
  4. Replies: 2
    Last Post: 09-11-2012, 09:42 AM
  5. [SOLVED] Edit code to close all workbooks except active workbook and other specific workbook
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2012, 09:29 PM

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