Excel: Code stops running after ThisWorkbook.Close


I have a workbook (Workbook1) that outputs data into a separate template file (Workbook2). code living in Workbook1 opens Workbook2, writes data to it, then makes Workbook2 the active window so the user can review and decide if they want to save it. If they want to save it, there is a button on the sheet in Workbook 2 which calls a save routine in Workbook1


sub butt*******()
application.run "workbook1.xlsm!SaveLocation"
end sub
For the longest time I couldn't figure out why in workbook1 SaveLocation,

sub SaveLocation()
'asking the user where to save
workbook2.close false
thisworkbook.close false
end sub
would quit running before closing workbook1. Then I finally realized, that once workbook2 is closed, all code stops because that is where I started from with the button. So, I changed workbook1 SaveLocation() and removed workbook2.close false. At the end of workbook2 butt*******(), I added thisworkbook.close false That didn't work. The code stops running after thisworkbook.close in workbook1 and workbook2 is still left open. Not sure why the name of the button click sub is being asterisked out, but it's butt*******() any help much appreciated


This question generated 12 answers. To proceed to the answers, click here.

This thread is current as of March 15, 2017.


For more resources for Microsoft Excel