ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing List Box Contents (https://www.excelbanter.com/excel-programming/327277-printing-list-box-contents.html)

Martyn Jones

Printing List Box Contents
 
Hi

Is there a way in Excel (VBA Code) to print to contents of a list box?

For example, I have an application that lists some financial figures
in a list box. Is there a way of sending these figures to a printer?

Martyn

Tom Ogilvy

Printing List Box Contents
 
Easiest would be to write them to a worksheet and print the range where they
are written.

An alternative is to use low level file io (guess it depends on what you are
actually doing)

Sub Macro5()
Dim ctrl as Long
Dim tmpstr as String
Open "LPT1:" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing ine " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub

If the printer is on a network, you would have to replace the LPT1 with the
network name.

--
Regards,
Tom Ogilvy


"Martyn Jones" wrote in message
om...
Hi

Is there a way in Excel (VBA Code) to print to contents of a list box?

For example, I have an application that lists some financial figures
in a list box. Is there a way of sending these figures to a printer?

Martyn





All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com