I worte a VBA snippet that calls a macro in another workbook written by my collegue. That macro actually calls python to do something else and create a new workbook. After that I need to open that new workbook and do some other things. However, the python code takes some time to run and if I simply use
Application.Run "'CollegueWorkbook.xlsm'!pythonmacro"
Set wb = Workbooks.Open("NewWorkbook.xlsx")
I will get Run-time error '9': Subscript out of range
beacause by the time Set wb = Workbooks.Open("NewWorkbook.xlsx")
is executed, the python code has not created a new workbook yet I guess (it looks like VBA code won't wait for python thread)
I wonder how I can let VBA to sleep and continue to next line of code only when the new workbook is produced. Or if there is any other workarounds?