Hi all. What I am about to do may seem odd but I'm not sure how else to do it. Earlier I was trying to find a thread that discussed how to print a text file. I found a ton of code, but the whole:
Open strFilePath For Input As #1
While not Eof(1)
Line Input #1, MyLine
Printer.Print MyLine & vbcrlf
was not working for me. The above code would print only the first line of text in the file.
I am posting this question to show how I arrived at my solution via a text stream. I am hoping to save some of you looking for this info a little time. The following code has worked flawlessly for me. It has maintained the printer margins (of course I have only tried the default margin settings for a txt file in notepad), printed all the pages as they came -- all without me having to code an end page or new page sub.
dim fso as new FileSystemObject
dim tst as TextStream
dim strline as string
dim strFilePath as string
strFilePath = gstrFilePath
If fso.FileExists(strFilePath) Then
Set tst = fso.OpenTextFile(strFilePath, ForReading, False)
Do Until tst.AtEndOfStream
strline = strline & tst.ReadLine & Chr(13)
Hope this helps you guys.