Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

How to have python wait until an Excel Macro/Refresh is done

$
0
0

I am using Python to run a macro in excel. and I want Python to close excel. The macro refreshes a data connection in excel which can be slow.

How do I have python wait until the refresh is done to close. This is what I am using, I need something before the xl.Quit that will wait until the refresh in macro is done????

 import win32com.client
 import os

 xl = win32com.client.DispatchEx("Excel.Application")
 wb = xl.workbooks.open("X:\Backoffice\Options Trading\BloombergRate.xlsm")
 xl.Visible = True
 xl.run("Refresh")
 xl.Quit()

Wait ways can I make this work?


Viewing all articles
Browse latest Browse all 88835