Solved

Remote printing with VB5

Posted on 1998-04-21
6
188 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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