AlJohri / docx2pdf

MIT License
506 stars 96 forks source link

Change close method to discard changes #33

Closed RussSchultz closed 3 years ago

RussSchultz commented 3 years ago

In our company's design flow, they generate docx files marked as 'ReadOnly' by some internal Word mechanism. If you open the file manually, Word prompts if you want to open it read only or not. The method of opening by docx2pdf apparently makes Word think you've opened it as write and wants to save changes.

Something recently changed in Word (I guess) that changes the error to docx2pdf such that it crashes it if you cancel the save window that pops up. This causes the script to bomb and not iterate over the batch items.

Changing doc.Close() to doc.Close(0) tell word to discard changes. I would use the proper enum for the option (wdDoNotSaveChanges) but I couldn't be arsed to figure out where in python-land that might be defined.

AlJohri commented 3 years ago

thanks @schnort this looks great!