AlJohri / docx2pdf

MIT License
506 stars 96 forks source link

new Window/Document instead of activeDocument #43

Closed Inqnuam closed 2 years ago

Inqnuam commented 2 years ago

Thanks for this very useful script! Just noticed that running the script while we are working on a document on Microsoft Word will close our document window. Could you please open the printing document inside a new window/document so we will dont lose our work? Thank you again

AlJohri commented 2 years ago

I'm not entirely sure if this is possible.

Assuming you're on windows, as you can see in the below snippet:

https://github.com/AlJohri/docx2pdf/blob/40169f76611ce4412f9e1669b56521bdfafae395/docx2pdf/__init__.py#L25-L27

The snippet is opening a document rather than relying on an "active" document. I think its best to just not actively have word open / use word during the conversion.

Inqnuam commented 2 years ago

I'm not entirely sure if this is possible.

Assuming you're on windows, as you can see in the below snippet:

https://github.com/AlJohri/docx2pdf/blob/40169f76611ce4412f9e1669b56521bdfafae395/docx2pdf/__init__.py#L25-L27

The snippet is opening a document rather than relying on an "active" document. I think its best to just not actively have word open / use word during the conversion.

The issue is related to macOS so on JSX side of the code

AlJohri commented 2 years ago

Got it. Attaching the relevant macOS snippet below. I see that it is indeed using activeDocument.

https://github.com/AlJohri/docx2pdf/blob/40169f76611ce4412f9e1669b56521bdfafae395/docx2pdf/convert.jxa#L131-L134

Doing a quick google search on other applescript and JXA implementations, it seems others are also relying on the "active document". I'm not sure if there's an alternative here.

links:

Inqnuam commented 2 years ago

Got it. Attaching the relevant macOS snippet below. I see that it is indeed using activeDocument.

https://github.com/AlJohri/docx2pdf/blob/40169f76611ce4412f9e1669b56521bdfafae395/docx2pdf/convert.jxa#L131-L134

Doing a quick google search on other applescript and JXA implementations, it seems others are also relying on the "active document". I'm not sure if there's an alternative here.

links:

What if we duplicate opening file into tmp directory then remove it after converting?