How to specify a printer via VB?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to display a list of printers installed on a PC, and allow the user to
select one of them for a report. I need to be able to do this from VB (long
story). Can someone point me in the right direction?

Thanks a million!
 
That link was helpful, but not exactly what I need. I need to display a list
of printers, and allow the user to select one . I don't need other printer
properties like paper type, page size, etc. Just a list of names. When the
user selects a name, that printer is used for the specific report. Access
2002.

Thanks!
 
Create a form with a listbox on it and use the following code:

Private Sub Form_Load()
Dim intCounter As Integer

For intCounter = 0 To Application.Printers.Count - 1
Me.lstPrinters.AddItem Application.Printers(intCounter).DeviceName(),
intCounter
Next intCounter

End Sub
That link was helpful, but not exactly what I need. I need to display a list
of printers, and allow the user to select one . I don't need other printer
properties like paper type, page size, etc. Just a list of names. When the
user selects a name, that printer is used for the specific report. Access
2002.

Thanks!
Check this link
[quoted text clipped - 5 lines]
 
Worked like a charm. Now, is there an easy way to set the selection as the
printer for that report ONLY?

Thanks!!

Gina via AccessMonster.com said:
Create a form with a listbox on it and use the following code:

Private Sub Form_Load()
Dim intCounter As Integer

For intCounter = 0 To Application.Printers.Count - 1
Me.lstPrinters.AddItem Application.Printers(intCounter).DeviceName(),
intCounter
Next intCounter

End Sub
That link was helpful, but not exactly what I need. I need to display a list
of printers, and allow the user to select one . I don't need other printer
properties like paper type, page size, etc. Just a list of names. When the
user selects a name, that printer is used for the specific report. Access
2002.

Thanks!
Check this link
[quoted text clipped - 5 lines]
Thanks a million!
 
What I did in my application was included a second list box with the names of
the reports that the user could print then I used the following code to set
the printer and output the report.

Dim stDocName As String

stDocName = Me.lstReports.Value()

If Len(stDocName) > 0 Then
'open the report in a hidden window
DoCmd.OpenReport stDocName, acViewPreview, , , acHidden

'set up printer
Reports(stDocName).Printer = Application.Printers(Me.lstPrinters.
ListIndex())
Reports(stDocName).Printer.Copies = Me.txtNumCopies.Value()

DoCmd.OpenReport stDocName, acNormal
End if

Its seems a bit convoluted, but it works. There is probably a much better way
of doing it.....

Gina
Worked like a charm. Now, is there an easy way to set the selection as the
printer for that report ONLY?

Thanks!!
Create a form with a listbox on it and use the following code:
[quoted text clipped - 21 lines]
 
Thanks a million! That should do it!

Gina via AccessMonster.com said:
What I did in my application was included a second list box with the names of
the reports that the user could print then I used the following code to set
the printer and output the report.

Dim stDocName As String

stDocName = Me.lstReports.Value()

If Len(stDocName) > 0 Then
'open the report in a hidden window
DoCmd.OpenReport stDocName, acViewPreview, , , acHidden

'set up printer
Reports(stDocName).Printer = Application.Printers(Me.lstPrinters.
ListIndex())
Reports(stDocName).Printer.Copies = Me.txtNumCopies.Value()

DoCmd.OpenReport stDocName, acNormal
End if

Its seems a bit convoluted, but it works. There is probably a much better way
of doing it.....

Gina
Worked like a charm. Now, is there an easy way to set the selection as the
printer for that report ONLY?

Thanks!!
Create a form with a listbox on it and use the following code:
[quoted text clipped - 21 lines]
Thanks a million!
 
Back
Top