?
Solved

Remote printing with VB5

Posted on 1998-04-21
6
Medium Priority
?
194 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
Technology Partners: 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 450 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 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