ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing an error report (https://www.excelbanter.com/excel-programming/282089-printing-error-report.html)

steve

Printing an error report
 


I'd like to print a simple error report from the application to the default network printer without using a worksheet. The text is in a string.

Any ideas?

Tom Ogilvy

Printing an error report
 
First, I went to the immediate window in the VBE to query the activeprinter
string

To a Network printer
? activePrinter
\\ARDAPS01\1D343E on Ne02:

then I used the first part in the below code:

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

Worked for me.

Regards,
Tom Ogilvy


"Steve" wrote in message
...


I'd like to print a simple error report from the application to the

default network printer without using a worksheet. The text is in a string.

Any ideas?





All times are GMT +1. The time now is 02:06 PM.

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