Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multiple Printers In VB

Posted on 2001-06-17
3
Medium Priority
?
196 Views
Last Modified: 2011-04-14
Hi,
Another printing problem - I am writing a POS System and it requires use of both a Laser Printer and a Reciept Printer - I need each one to perform the task it is assigned to without selecting a printer each time for each task ie: Reciept Printer Prints Reciepts and the Laser prints reports - I used to know how to put all printers on the system into an array, but have long forgotten how to, any help will be appreciated - Best scenario is to get all system printers into a combo box.

Thanks,
Tom
0
Comment
Question by:flosoft
  • 2
3 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 6200490
0
 
LVL 33

Accepted Solution

by:
hongjun earned 400 total points
ID: 6200495
To make you more convenient, I decided to post the code from the link here.

Private Sub Form_Load()
    PopulateListControlWithPrinters Combo1
End Sub

Private Function PopulateListControlWithPrinters(ListControl As _
Object) As Boolean

On Error GoTo errHandler:
Dim l As Long
Dim lCount As Long
ListControl.Clear

lCount = Printers.Count

If lCount = 0 Then
    ListControl.AddItem "(No Printer Installed)"
Else
    For l = 0 To lCount - 1
        ListControl.AddItem Printers(l).DeviceName
    Next
End If

PopulateListControlWithPrinters = True

Exit Function
errHandler:
PopulateListControlWithPrinters = False
Exit Function

End Function

hongjun
0
 

Author Comment

by:flosoft
ID: 6200756
Thanks for the code - Do you know if the combo box's item(#) corresponds exactly to the printers(#) number in the index? - Then all's I would have to save to the registry is the combo's selected index value.

Thanks again.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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

916 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