Solved

Print a Text File

Posted on 2000-02-23
4
292 Views
Last Modified: 2010-05-02
Can I print a .txt file without opening it first? No formatting or page breaks are required. All I would need is for the program to print a predetermined file name and quit.
0
Comment
Question by:DonH040699
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
kamall earned 35 total points
ID: 2553161
Open "c:\myfile.txt" For Input As #1
Do while Not Eof(1)
   Line Input #1, x$
   Printer.Print x$
Loop
Close 1
Printer.EndDoc

0
 
LVL 5

Expert Comment

by:KDivad
ID: 2553284
Without opening it? Sure, if you don't mind "bouncing" it off command.com.

x = Shell("command /c copy " & MyFile & " lpt1")
0
 

Author Comment

by:DonH040699
ID: 2567112
Kamall,

I put your suggested code in a function and it worked great. VB showed me what else I could do with Print. and I wound up with a very useful untility. Thanks!
0
 
LVL 7

Expert Comment

by:kamall
ID: 2582143
You are welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now