Closed mspicer closed 6 years ago
Hi
When working with Office, there's always the possibility of it triggering dialogs because it's not designed to be used un-attended.
Some things that may help:
Unfortunately, there's no magic bullet that can guarantee documents convert without intervention - Word documents are just too variable.
Thank you for feedback!! I will try to add a delay to the code, that's a great idea. I wil ltry the /word_field_quick_update option as well. I've tried the /readonly option without any success, but maybe combine with the other it will work. I will report back.
Side question, are there compiling instructions or a dependency list? I've opened the .sln file in Visual Studio 2012 Express and am trying to build a debugging binary so that I can step through execution to see what the state is when it fails. Also another thing I'd like to consider adding is to add a timer and after X seconds close the program because its likely not going to convert. I've seen some issues with some of my docx files where the program simply hangs. If I can figure this out, I'd be glad to contribute my code back.
In the project are missing some dependencies, i added the Office Primary Interop Assemblies with a NuGet Package and it worked.
Interop.Microsoft.Office.Interop.OneNote Interop.Microsoft.Office.Interop.Publisher Microsoft.Office.Interop.Excel Microsoft.Office.Interop.Outlook Microsoft.Office.Interop.PowerPoint Microsoft.Office.Interop.Word Visio2010.PrimaryInteropAssembly Visio2013.PrimaryInteropAssembly
Awesome, I'll give that a try.
Thanks!!
The issue comes when I'm trying to iterate through a group of files and convert them all to PDF. Here is the BAT script I am trying to use:
for %%f in (*.docx) do ( echo %%~nf OfficeToPDF.exe "%%~nf.docx" "%%~nf.pdf" )
The first file generates and then subsequent files do not and the command line give the following error: _Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALLREJECTED)) Did not convert
Other times when I run the script it creates a few files then hangs. And sometimes when I run the script MS Word opens with a message that document1 has been modified, would you like to save it.
Let me know your thoughts.