Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the bug that office program will shutdown once running the OfficeToPDF.exe command line tool #54

Conversation

wenzai007
Copy link

@wenzai007 wenzai007 commented Oct 2, 2019

This is for issue #53

While I am using outlook to view and deal with messages, and at same time I want to convert some messages into PDF, but whenever I run the command line .\OfficeToPDF.exe '.\outlookmessage.msg' 'convertedNewFile.pdf' it will shutdown the Word.exe and Outlook.exe, which is very inconvenient, why it would act like this, (from source code, seems it will release the session?
After debugging, I found that
in OutlookConverter.cs
try { app = (Microsoft.Office.Interop.Outlook.Application)Marshal.GetActiveObject("Outlook.Application"); } catch(System.Exception) { app = new Microsoft.Office.Interop.Outlook.Application(); running = false; } )

// If we were not already running, quit and release the outlook object if (app != null && !running) { ((Microsoft.Office.Interop.Outlook._Application)app).Quit(); }
Why would we affect the current running app and session? Could we not shutdown the Outlook and Word app when running the converting job?

I tried to fix it to make the initial variable options["noquit"] to true. I think it makes more sense.

@wenzai007
Copy link
Author

Just found out that there is a /noquit switch, then it's fine to close it. I will abandon the PR #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant