none
"my lines of" VBA cause Excel to crash RRS feed

  • Question

  • Hello,

    I use a starter application to start specific Excel applications. After opening the desired workbook I want to close the "calling" workbook. The following, in shorthand, code is used for this purpose but crashes Excel 2007, windows 10, 64bit.

    Starterapp

    The desired app is opened with the following line of code.

    workbooks("DesiredApp").open 
    

    DesiredApp

    After opening in the Workbook_open sub the following line closes the calling app

    Workbooks("StarterApp").close (0)

    This causes Excel to crash.

    Question:

    Is there a way to close a running workbook with active VBA without causing this problem or is there a way to start the "DesiredApp"  workbook running without the calling app to wait en follow it's own code to cleanly stop the starting app. Maybe there is a method like "call" or "run" that will do the trick.

    I hope this way of asking the question is understandable.

    Thanks in advance.

    Dick

    Tuesday, December 22, 2015 12:53 PM

Answers

  • In itself, that shouldn't cause Excel to crash. I tested it and the calling workbook was closed from the workbook being opened without problems.

    But perhaps there is other code in the calling workbook that interferes?

    By the way, you could also let the calling workbook close itself:

        Workbooks.Open "Path and name of workbook"
        ThisWorkbook.Close SaveChanges:=False

    but keep in mind that no code below this will be run.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)


    Tuesday, December 22, 2015 2:07 PM

All replies

  • In itself, that shouldn't cause Excel to crash. I tested it and the calling workbook was closed from the workbook being opened without problems.

    But perhaps there is other code in the calling workbook that interferes?

    By the way, you could also let the calling workbook close itself:

        Workbooks.Open "Path and name of workbook"
        ThisWorkbook.Close SaveChanges:=False

    but keep in mind that no code below this will be run.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)


    Tuesday, December 22, 2015 2:07 PM
  • Thanks for your reply.

    I will test further and when I still encounter problems I will reply in this thread.

    I sometimes get the impression that an Excel application, when active for a long time, gets instable. What is your opinion on that?

    Tuesday, December 22, 2015 8:12 PM
  • I have Excel applications that have been used for years without problems...

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, December 22, 2015 10:19 PM
  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excel
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Regards,

    Emi Zhang
    TechNet Community Support


    Please mark the reply as an answer if you find it is helpful.

    If you have feedback for TechNet Support, contact tnmff@microsoft.com.
    Wednesday, December 23, 2015 9:15 AM
  • Hi, dickindeventer

    If you want to open a workbook, you could use Workbooks.Open Method (Excel), you could refer to below code:

    Workbooks.Open "DesiredApp file path" 

    For more information, click here to refer about Workbooks.Open Method (Excel)

    Thursday, December 24, 2015 7:55 AM