Solved

Multiple Printers In VB

Posted on 2001-06-17
3
190 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

830 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