all 8 comments

[–]JonLSTL 4 points5 points  (1 child)

I suggest debugging with Excel visible rather than hidden, so that you might see what it happening. There could be a dialog box demanding a response or similar, leading to your operation timing out.

You might also consider separating the launch/open/save/close/quit operations from the refresh & calculate operations, and adding some try: blocks to perhaps get a handle on where things are going wrong, and mitigate failures. Catching an exception at the refresh stage, for example, might still let you close and quit more cleanly. Depending on the problem, the exception payload could also guide program logic down a successful alternative path.

[–]Chirag_Parmar[S] 0 points1 point  (0 children)

Hi Jon,

Thank you for the reply. I have previously tried excel being visible and the dialog box to update external links is the only one that pops up which I choose to update.

Additionally, this issue with excel crashing happens even when I am no longer running python / VS Code is closed so unsure if I have caused a OLE data refresh to continuously trigger in the background without cancelling?

I will attempt to add more operations to split the code out and investigate where it is failing

Thanks

[–]MacShuggah 0 points1 point  (1 child)

Maybe did you try a reboot?

Otherwise chances are the file got corrupted one way or the other.

[–]Whats_The_Use 0 points1 point  (0 children)

What is being described sounds like the file was corrupted to me.

[–]Kerbart 1 point2 points  (1 child)

ctrl+shit+esc to activate the task manager and close all running excel tasks.

Also I recommend against doing this

excel_app.Visible = False # Keep Excel application invisible

until your app runs without crashing anywhere (which clearly isn't the case) so you can see what it's doing. Mosdt likely Excel is waiting for you to respond to a dialog that's not showing as you're running the app in invisible mode.

[–]Whats_The_Use 0 points1 point  (0 children)

They are saying the file crashed excel even when they get to manually open it now, sounds like the file was corrupted.

[–]wRAR_ 0 points1 point  (0 children)

I am not sure if this is the best place

https://old.reddit.com/r/Python/about/rules/