1

I would like to open a excel file from a python script, and wait that the user closes the Excel application.

xl = win32com.client.DispatchEx("Excel.Application")
xl.Visible = True
wb = xl.Workbooks.Open(dir+"/my.csv")
wb.RefreshAll()
#wait for xl closes
#continue scripts

But I could find any method in win32com to do it.

7
  • see stackoverflow.com/a/19390275/3025412. Does it help? Commented Dec 20, 2016 at 13:40
  • Thanks, I read it, but it doesn't state if a wait can be made on the Workbooks resources such as in the subporocess module. It can only be used to make an active wait by polling if excel has an instance running. I am looking for an event/notify way Commented Dec 20, 2016 at 14:29
  • If you can get a reference on the workbook you need you can check in a while loop until that reference becomes invalid (ie the user closes the workbook). That is however blocking the rest of the script from executing. This is what you want, right? Commented Dec 20, 2016 at 19:54
  • yes it is. But using a while loop is not the better way. A good way, is to have a notification when excel close is a good way, such as the wait method of the subprocess module. Commented Dec 21, 2016 at 9:10
  • is there a way to get a subprocess object from a workbook object? Commented Dec 21, 2016 at 10:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.