P
Peter
I'm using prnadmin.dll via a Word VBA macro (for those who want to read it, I'll paste the code to the end of this message) to setup a file printer to generate PCL5-compliant image files for faxing software that we're using.
I'm using a printer driver that is bundled in Windows, the HP LaserJet III, and installing the printer to the port "FILE:".
The installation goes perfectly, and I then set some properties of the printer, such as the comment, the datatype, the location, etc....
Now, here are my questions:
Another macro then prints to that printer, generating a fax file, and I've noticed that the printer icon in the System Tray lingers around for a long time (perhaps 30 seconds to 1 minute) after the file is produced and the status, according to the tooltip when I hover my mouse pointer over the System Tray icon, is "1 document(s) pending". Double-clicking the icon brings up the queue window, which shows no documents pending. Any ideas on why it may be hanging around so long? It doesn't seem to have a deleterious effect; I can run the printing code immediately and produce another file.
Secondly, I have tentatively deployed this to a Win2k Terminal Services server with about 10 users. The server has about 10 networked printers installed. I noticed after I deployed my macros and the users had installed and were printing to the PCL5 fax printer (all via the VBA macros), that most of the networked printers somehow obtained a status of "Opening", and that my code was hanging at the line
Call oMaster.PrinterGet("", FAXPRINTER, oPrinter)
Trying to retrieve the fax printer in order to test for its existence.
This happened twice. I had to reboot the server each time, and am watching it closely now.
Any ideas on using prnadmin in a multi-user environment?
Of course, I have no proof that the situation was caused by prnadmin, but the coincidence is suggestive.
thanks,
-Peter
Private Sub InstallPrinter()
Const FAXPRINTER as String = "PCL5 fax printer"
Static Registered As Boolean
Dim oPrinter As Object
Dim oMaster As Object
On Error Resume Next
Set oMaster = CreateObject("PrintMaster.PrintMaster.1")
Set oPrinter = CreateObject("Printer.Printer.1")
If Err.Number = 429 Then ' prnadmin.dll has not been registered
' attempt to register it, then call this sub again, but only once.
If Not Registered Then
Call Shell("regsvr32 /S prnadmin.dll", vbHide)
Registered = True
Call InstallPrinter
End If
Exit Sub
End If
' check for the existance of the fax printer
Call oMaster.PrinterGet("", FAXPRINTER, oPrinter)
If Err.Number = -2147023095 Then
' the printer has not yet been installed, so install it using prnadmin.dll from the W2k reskit.
Err.Clear
oPrinter.ServerName = "" ' local computer
oPrinter.PrinterName = FAXPRINTER
oPrinter.DriverName = "HP LaserJet III"
oPrinter.PortName = "FILE:"
' DriverPath and InfFile both default to the standard location. W2k and XP should install with support for the HP LaserJet III printer.
' If we change the printer or find that 2k/XP doesn't always support the HP LJ III, we need to bundle driver and inf files with our app and point DriverPath and InfFile to that location, which isn't hard to do.
Call oMaster.PrinterAdd(oPrinter)
If Err.Number = 0 Then
' set the properties of the just-installed printer
oMaster.PrinterGet "", FAXPRINTER, oPrinter
oPrinter.Comment = "PCL 5 fax printer"
oPrinter.Location = "Local Computer"
oPrinter.DataType = "RAW"
oPrinter.Default = False
oPrinter.Shared = False
oMaster.PrinterSet oPrinter
End If
End If
Set oPrinter = Nothing
Set oMaster = Nothing
End Sub
I'm using a printer driver that is bundled in Windows, the HP LaserJet III, and installing the printer to the port "FILE:".
The installation goes perfectly, and I then set some properties of the printer, such as the comment, the datatype, the location, etc....
Now, here are my questions:
Another macro then prints to that printer, generating a fax file, and I've noticed that the printer icon in the System Tray lingers around for a long time (perhaps 30 seconds to 1 minute) after the file is produced and the status, according to the tooltip when I hover my mouse pointer over the System Tray icon, is "1 document(s) pending". Double-clicking the icon brings up the queue window, which shows no documents pending. Any ideas on why it may be hanging around so long? It doesn't seem to have a deleterious effect; I can run the printing code immediately and produce another file.
Secondly, I have tentatively deployed this to a Win2k Terminal Services server with about 10 users. The server has about 10 networked printers installed. I noticed after I deployed my macros and the users had installed and were printing to the PCL5 fax printer (all via the VBA macros), that most of the networked printers somehow obtained a status of "Opening", and that my code was hanging at the line
Call oMaster.PrinterGet("", FAXPRINTER, oPrinter)
Trying to retrieve the fax printer in order to test for its existence.
This happened twice. I had to reboot the server each time, and am watching it closely now.
Any ideas on using prnadmin in a multi-user environment?
Of course, I have no proof that the situation was caused by prnadmin, but the coincidence is suggestive.
thanks,
-Peter
Private Sub InstallPrinter()
Const FAXPRINTER as String = "PCL5 fax printer"
Static Registered As Boolean
Dim oPrinter As Object
Dim oMaster As Object
On Error Resume Next
Set oMaster = CreateObject("PrintMaster.PrintMaster.1")
Set oPrinter = CreateObject("Printer.Printer.1")
If Err.Number = 429 Then ' prnadmin.dll has not been registered
' attempt to register it, then call this sub again, but only once.
If Not Registered Then
Call Shell("regsvr32 /S prnadmin.dll", vbHide)
Registered = True
Call InstallPrinter
End If
Exit Sub
End If
' check for the existance of the fax printer
Call oMaster.PrinterGet("", FAXPRINTER, oPrinter)
If Err.Number = -2147023095 Then
' the printer has not yet been installed, so install it using prnadmin.dll from the W2k reskit.
Err.Clear
oPrinter.ServerName = "" ' local computer
oPrinter.PrinterName = FAXPRINTER
oPrinter.DriverName = "HP LaserJet III"
oPrinter.PortName = "FILE:"
' DriverPath and InfFile both default to the standard location. W2k and XP should install with support for the HP LaserJet III printer.
' If we change the printer or find that 2k/XP doesn't always support the HP LJ III, we need to bundle driver and inf files with our app and point DriverPath and InfFile to that location, which isn't hard to do.
Call oMaster.PrinterAdd(oPrinter)
If Err.Number = 0 Then
' set the properties of the just-installed printer
oMaster.PrinterGet "", FAXPRINTER, oPrinter
oPrinter.Comment = "PCL 5 fax printer"
oPrinter.Location = "Local Computer"
oPrinter.DataType = "RAW"
oPrinter.Default = False
oPrinter.Shared = False
oMaster.PrinterSet oPrinter
End If
End If
Set oPrinter = Nothing
Set oMaster = Nothing
End Sub