Solved

printing to a remote printer

Posted on 2003-11-19
7
232 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now