Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing DLL returns error message when accessed from ASP

Status
Not open for further replies.

PoppapumpJ

Programmer
Dec 17, 2001
86
US
Hi,

I have written a DLL to generate the prints of certain print outs.

The Printer to print to is supplied as a property.

Everything works fine when accessing through a VB application. However, when I run the same code in ASP, it returns the following error:

Problem getting printer information from the system. Make sure the printer is set up correctly

The DLL is housed and registered on the server and the same printer works when Accessed through a VB App.

Below is the code of the DLL:
[tt]
Public Sub DoPrint()
On Error GoTo errHandler

Dim strPrintString
Dim myPrinter


'define string to print
strPrintString = "hello Printer"

'see if the supplied printer is installed on this server
Set myPrinter = GetPrinter

'send the print string to the document
Printer.Print strPrintString

'create a barcode and where to put it
PaintCodeBar39 Printer, 100, 100, 100, 5, "*SO45874874*", True

'end the document and send it to the printer
Printer.EndDoc

GoTo xit

errHandler:
errNumber = Err.Number
errDescription = Err.Description

xit:
Exit Sub


End Sub




Private Function GetPrinter()
Dim P

'loop through installed printers to see if supplied printer is installed
For Each P In Printers
If P.DeviceName = PrintTo Then
'if installed, set printer to it and exit loop
Set Printer = P
Exit For
End If
Next


'if retrieved printer is anything other than supplied printer, than it was not installed
'this is required because the Printer object is set to the server's default
'even if the supplied printer is not installed
If Printer.DeviceName <> PrintTo Then
'raise an error
Err.Raise vbObjectError - 90, "GetPrinter", "Printer " & PrintTo & " is not installed on the server"
Exit Function
Else
'return correct printer object
Set GetPrinter = Printer
End If

End Function[/tt]
 
Have you tried printing something directly from that server?
It sounds like the printers aren't setup correctly on the web server.
 
Thanks for the response,

Yes, I have been able to successfully print from the server using Word and my DLL. But the DLL only works when accessed through a custom VB app, not ASP.

One odd thing...
Even though I can see all my installed printers in Settings>printers, no printers are displayed when I go to
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top