Solved

Remote printing with VB5

Posted on 1998-04-21
6
186 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

762 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

26 Experts available now in Live!

Get 1:1 Help Now