Excel – “No printers are installed” printing from Excel via COM

comexcelwindows-server

I have LotusScript code running in IBM Domino 9.0 on a 64-bit Windows 2012 R2 server, which uses COM to launch Microsoft Excel 2010, open a workbook, then print via PDFCreator (from PDFForge) to convert the workbook to a PDF.
IBM Domino is running as a service under the SYSTEM user, so Excel and PDFCreator also run under that user when started by my code.

This was working fine until two days ago, then PDFCreator started hanging on launch for no reason that I've determined.

One of the admins for the customer reinstalled Excel and PDFCreator, and also deleted a Windows user profile (though I don't know for which user). Now PDFCreator is starting OK, but there have been several issues with Excel.

I fixed some Excel issues with changes to my code and to the OS file system, but the problem now is when my code tells Excel to print the workbook, this error occurs:

Microsoft Excel: No printers are installed. To install a printer click the File tab, and then click Print.
Click No Printers Installed, and then click Add Printer. Follow the instructions in the Add Printer dialog box.

This error only occurs when trying to print with my code.
I can launch Excel as an admin user and print manually, with three printers (including PDFCreator) available in the Print dialogue-box.

It seems to me that the printers are just not visible to the SYSTEM user, but I have no idea how to verify or fix this.
What can I do about it?

Several bits of code follow. I've removed some error handling and other things for brevity.

The following code starts PDFCreator:

Set pdfCreator=CreateObject("PDFCreator.clsPDFCreator")
If pdfCreator.cStart("/ClearCache /NoProcessingAtStartup") Then
    pdfCreator.cClearCache
    pdfCreator.cOption("PrinterTemppath")=pdfTmpDir
    pdfCreator.cOption("UseAutosave")=1
    pdfCreator.cOption("UseAutosaveDirectory")=1
    pdfCreator.cOption("AutosaveDirectory")=pdfTmpDir
    pdfCreator.cOption("AutosaveFormat")=0
    pdfCreator.cSaveOptions
    pdfCreator.cDefaultPrinter="PDFCreator"
End If

pdfTmpDir is a string variable containing a directory path, set elsewhere in the code.

These lines start Excel:

Set xlApp=CreateObject("Excel.Application")
xlApp.Visible=False

These lines open an existing workbook and print it.

Set xlBook=xlApp.Workbooks.Open(ceBCMSheet)
xlBook.PrintOut ,,1,False,"PDFCreator"

ceBCMSheet is a string variable containing the full path to an XLS file, set elsewhere in the code.

Best Answer

I've been able to fix this by editing the registry on the Windows server.

I found printers listed for the admin user in the "Devices" and "PrinterPorts" children of this registry key:
HKEY_USERS\S-1-5-19\Software\Microsoft\Windows NT\CurrentVersion

I copied those keys to the ".DEFAULT" user, and now my code runs with no errors.

Related Topic