0

I'm using a library called Excel2Image in order to take a sheet range in excel and save it as a video. This library uses win32com in order to get an excel application.

Inside of my main program, consistently when I call the library's 'export_img' function, at one specific point in the function, the python program terminates despite having no exit, quit or sys.exit type of function. There isn't an error or anything. It's just as if the program finished running normally. I went inside of the export_img function to find out what could be doing this

        print(rng.Parent)
        print('-')
        for shape in rng.Parent.Shapes:
            print(shape)
        print('Checkpoint 2.2')
        shape = None
        del shape

        print('Checkpoint 3')

where rng is a worksheet cell range object (rng = excel.workbook.Application.Range(_range))

The program terminates at the for loop, not printing a single shape. Nothing after, like "Checkpoint 2.2" gets printed, so something strange happens in that for loop.

Before the edits, the line was just for shape in rng.Parent.Shapes: pass. The program prints everything up until the for loop where the program just ends. It doesn't print any shape nor execute any code afterwards. It consistently happens at one part of the program but I couldn't find out what about it actually causes it to fail. I tried adding a "try except" and use traceback to find an error if it was surpressed or something, but still nothing came up and the program terminated.

2
  • Probably local to your system. Have you tried a different workbook and PC? As you say you have the code and can see what it's doing so should be able to do some more debugging. Commented Jul 12, 2024 at 12:29
  • I was able to get around this error by getting the excel application with DispatchEx instead of EnsureDispatch, but this also brought up unrelated problems that I was barely able to deal with Commented Jul 12, 2024 at 17:15

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.