Hello Dan,
We are using COM automation to run Word from an application running in a service context under a local user profile with administrative rights (the profile is a member of the local administrators group). The application driving Word has been used (and
is actively developed/maintained) since 1998 with Word versions from 97 upto 2016.
We have consistently observed the exact behavior described in this thread / the KB articles (two jobs successful, after that random success or failure) on both Windows 2008R2 and Windows 2012R2, and with both Office 2010 (current patchlevel) and Office 2013
SP1 (no further patches). A significant percentage of the jobs fail.
The document format (DOC or DOCX) did not matter. I haven't verified if the rendering engine (Esher vs. Esher2) mattered for DOCX, but Esher should be covered by the DOC path anyway.
We did try to confirm the KB3177725 relationship first by patching a 2008R2 server upto the current patch level and then deinstalling KB3177725 -- which fixed the problem introduced after the patching, and on a 2012R2 server (with patch level june or july
2015), where we only installed KB3177725 (downloaded and installed manually, not through WindowsUpdate) -- which introduced the problem. I think this confirmed KB3177725 as the trigger of the observed behavior.
At this time I am unable to verify Office 2016 on a fully patched 2012R2 server, as for some reason Windows Update refused to offer me KB3177725 for Windows 2012R2 today, nor any other fix that could be somehow associated with MS16-098 through the KB
numbers.
All reproductions were done using the Amyuni v5 PDF printer driver. We are using an older revision (I think 5.0.0.7 or 5.0.1.2) that has been in use by us for at least two years.
All components (OS, Office and PDF printer driver) are 64-bit. Our own application driving the automation is 32-bit.
The following automation sequence is executed (these are the exact commands, but I left out options like 'open-read-only', 'do-not-print-in-background' as I don't have the exact code available at this time):
[Edit: See full repo script in reply below]
Documents.Open "c:\temp\test.docx"
WordBasic.FilePrintSetup Printer:="PDF driver" DoNotSetAsSysDefault:=True
Document.PrintOut OutputFileName:="c:\temp\spool1.pdf"
Document.Close wdDoNotSaveChanges
Documents.Open "c:\temp\test.docx"
Document.PrintOut OutputFileName:="c:\temp\spool2.pdf"
Document.Close wdDoNotSaveChanges
Documents.Open "c:\temp\test.docx"
Document.PrintOut OutputFileName:="c:\temp\spool3.pdf"
Document.Close wdDoNotSaveChanges
Documents.Open "c:\temp\test.docx"
Document.PrintOut OutputFileName:="c:\temp\spool4.pdf"
Document.Close wdDoNotSaveChanges
...
So the printer is only set during the first print sequence. All print sequences use the same document, but generate new spool files. Note that we are explicitly instructing Word to use the 'print-to-file' options.
The content of the document seems to be irrelevant. I could reproduce the problem with a single-page document only containing the text generated by =lorem(5,5). I don't recall if the document was A4 or US Letter.
The resulting PDF files are either OK, or seem to be missing all page content (and therefore technically corrupt).
Restarting Word after every print fixes the problem.
We haven't had time to do much more testing or work on isolating a stand-alone reproduction scenario as our focus is still on damage control / finding workarounds for our customers.
UPDATE #1:
First tests:
Service context and application are a red herring. The problem reproduces interactively on the desktop with a trivial VBS script.
UPDATE #2:
More testing:
The printing device is a red herring as well. The problem reproduces with the (preinstalled) Microsoft XPS Document Writer driver as well. XPS files are either 107KB and OK, or 10KB and 7-Zip reports an error when I try to unzip.
UPDATE #3:
Uninstalling KB3177725 fixes the problem and generates consistent 107KB XPS files.
UPDATE #4:
Office 2016 (Click-to-Run install) is broken too.
(Final) UPDATE #5:
Due to the 'random' sort that Explorer performs on the 'Date Modified' field when all documents are produced in the same minute I hadn't noticed it yet, but the repro script consistently produces an OK / Broken sequence (so Spool 2, 4 and 6 are broken, the
odd ones are OK). This deviates from the 'first two jobs are OK'. All prints are the same 1 page document.
Regards,
Stefan
E: stefan(dot)ten[no-dot]hoedt(at)outlook(dot)com
[Edit: added remark on print-to-file]
[Edit: added contact info]
[Edit: updated multiple times with additional test results, strike-through for obsolete information/red herrings]