Originally Posted by
alcapps
what I found is you must set some cell in the spreadsheet to a value and have your code wait till the value is present to do the close.
access will execute the macro and then close before the macro is finished.
so in your excel macro set a cell some where to nothing. and Have the excel macro change it to "Done" when the excel macro is complete.
in access have it wait for the cell to have "done" in it.
this way excel will finish the macro and access will close excel only when your macro is complete.
'Step 3: Run the target macro
xl.Run "mymac"
'Add this code and point to the excel cell you want to use.
do while not (excel cell) = "Done"
doevents
loop
'Step 4: Close and save the workbook, then close Excel
xl.ActiveWorkbook.Close (True)
xl.Quit