vba - Excel workbook only shows after running code is finished -
i have program in excel workbook opens powerpoint-file, updates links within file , closes after that. works fine. here problem: when links updated excel file source data opened. after powerpoint closed file stays open. want closed because repeat process many files , can't end hundreds of open excel files.
i tried following:
wbks=application.workbooks.count = wbks 1 step -1 if workbooks(i).name<>thisworkbook.name workbooks(i).close savechanges:=false end if next
now comes weird part. whenever run code, wbks returns 1 , excel file pops after code finished. if go through code in debug mode works. workbook pops enter debug mode.
i tried applicatio.wait
in hope file show after second. file showed after code finished.
i tried do while loop
wait until file open. excel crashes because never leave loop.
edit: tried doevents
suggested. not work either.
this workaround, try using brute force after x times macro has run. store x somewhere in workbook, save. , kill excel process (all instances, including self) :
dim skill string skill = "taskkill /f /im excel.exe" shell skill, vbhide
found here : vba script close every instance of excel except itself
when running macro next time, use x starting point next ppt file update.
Comments
Post a Comment