Solved

printing to a remote printer

Posted on 2003-11-19
7
234 Views
Last Modified: 2010-05-03
i am writing an application which requires me to print to a dot matrix printer

hence to print i wrote the following code

Open "\\Node1\Epson" For Output As #1
Print #1, "Text to be printed "
Close #1


now, we have two machine node1 and node2 the printer is physially attached to node1 and the share name of the printer is Epson, when i run my application on node2 the print output is perfect with no errors

but when i try to print from node1 itself i get the following error
Run time error "52"
Bad file name or number

can some one help me with the problem

0
Comment
Question by:alifyusuf
  • 2
7 Comments
 
LVL 3

Expert Comment

by:ToolMan
ID: 9786030
Hi,
Maybe the second node can't be resolved by your operatingsystem,
you should be able to ping your nodes and see whether you can print from e.g. notepad.

regards
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9786239
I think you'll have to use the printer object.

0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 150 total points
ID: 9786450
If you do have to use the printer object, you can do it like this.

It might be worth trying, even if you don't plan to use it in the long run, because you might get a different and more informative error message.

The printers must set up on your workstation with different names, e.g. Epson1 & Epson2

Dim prn As Printer

'Find the printer by name
For Each prn In Printers
  If prn.DeviceName = ("Epson1") Then
    Exit For
  End If
Next prn

'Set the printer object
Set Printer = prn

Printer.Print "Text to be printed"
Printer.NewPage
Printer.EndDoc
0
 
LVL 28

Assisted Solution

by:vinnyd79
vinnyd79 earned 150 total points
ID: 9788530
Have you tried this on Node1:

Open "LPT1" For Output As #1
Print #1, "Text to be printed "
Close #1


0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question