Solved

Remote printing with VB5

Posted on 1998-04-21
6
191 Views
Last Modified: 2008-03-06
I have a PCL file : test.prn.
I have a printer remotely connected : HP LaserJet 5 on SRV02 (\\SRV02\HP LaserJet 5).

I want to do 2 things :

1. A list of printers on the computer with the network path for remote printers.

For example :

HP LaserJet 4
HP LaserJet 5 - \\SRV02\HP LaserJet 5

2. I want to send the file to the printer.

How can I do ? I've tried with OpenPrinter, AddJob, ScheduleJob but AddJob doesn't work for remote printers.
I have had some problems with the types used bye these functions.

Can someone give me some code samples ?

If the answer is too long, e-mail me at greisch@euronet.be.

Patrick Vanhuyse
0
Comment
Question by:greisch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 3

Author Comment

by:greisch
ID: 1426107
Adjusted points to 150
0
 

Expert Comment

by:duc
ID: 1426108
Question 1
Sub main()
Dim X As Printer
For Each X In Printers
    Debug.Print X.DeviceName
    Set Printer = X
Next
End Sub

Duc

0
 
LVL 3

Author Comment

by:greisch
ID: 1426109
Hello Duc,

You get only the LOCAL device name (HP LaserJet 5), not the remote path to the device (\\SRV02\HP LaserJet 5).

Thanks.

Pat
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:duc
ID: 1426110
Hi Pat
In our installation it gives me the following

\\ZHSV57204\L4_ZF104
\\ZHSV57204\L4_ZF122

so it seems not to be a VB issue.

Regards
duc

0
 

Accepted Solution

by:
duc earned 150 total points
ID: 1426111
Hi Pat
I have a solution which works, not very sophisticated but... here the code:
Sub main()
  CheckFile = Dir("C:\PRINT.BAT")
  If CheckFile <> "" Then
   Kill "C:\PRINT.BAT"
  End If
  RetVal = Shell("notepad.exe", 1)
  SendKeys "C:\WINNT\SYSTEM32\print /d:\\ZHSV57204\L4_ZF122 C:\test.prn", True
  SendKeys "{ENTER}"
  SendKeys "%{F4}", True
  SendKeys "{ENTER}", True
  SendKeys "C:\PRINT.BAT", True
  SendKeys "{ENTER}", True
 
  RetVal = Shell("C:\PRINT.BAT", 0)
 
End Sub
0
 
LVL 3

Author Comment

by:greisch
ID: 1426112
Hi Duc,

You were right for the question 1.

When I test it, I was on the server !!!

Sorry.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

737 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