yasha Posted November 12, 2018 Share Posted November 12, 2018 $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel.Workbooks.Open('J:\OPS\OPS_Share\Planners\7 - Automation\All Report macro.XLSM',0) $oExcel.ActiveWorkbook.Application.Run("ECONOMICSTOCKCOMPILE") $oExcel.ActiveWorkBook.Close $oExcel.Quit WEnd ;ProcessWaitClose("Proce.exe") WinWaitActive(""& $YY & $MM & $DD & "range_Economic_stock.xls") $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel.ActiveWorkbook.SaveAs ( $sFileSelectFolder &"\"& $YY & $MM & $DD & " range_Economic_stock.xlsx",51,"","",False,False) $oExcel.ActiveWorkBook.Close $oExcel.Quit my program runs fine only problem is that it does not wait till macro finishes any idea how wait until macro finishes . Link to comment Share on other sites More sharing options...
Marc Posted November 12, 2018 Share Posted November 12, 2018 If only one instance of excel is running (which is started by your script) you could simply use WinWaitclose. or while 1 if not ProcessExists("excel.exe") Then ExitLoop Sleep(250) wend yasha 1 Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 12, 2018 Share Posted November 12, 2018 @yasha You could use _Excel_* functions to interact with Excel yasha 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
yasha Posted November 12, 2018 Author Share Posted November 12, 2018 (edited) @FrancescoDiMuro ah thanks for your replies turns out i forget to add save function in macro so it closed the program after the macro ran but did not save my file so the autoit got stuck waiting for excel to activate lol . Edited November 12, 2018 by yasha Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now