HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR 
Author Message
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR

does anyone kno any command or method or anything that will enable me to
rpint text files directly.

for example, say you store data in test.txt. you press a button, and
voila, the printer is activated printing the file.

Keyur Patel
Houston, TX



Fri, 11 Jun 1999 03:00:00 GMT  
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR



Quote:
> does anyone kno any command or method or anything that will enable me to
> rpint text files directly.

> for example, say you store data in test.txt. you press a button, and
> voila, the printer is activated printing the file.

Uhh...that's really REALLY easy...you should read the helpfiles thoroughly
before you ask questions like this.

'---------------------------------------------
x = FreeFile
Open "test.txt" For Input As x
  s$ = Input$(Lof(x),x)
Close x

Printer.Print s$;
Printer.EndDoc
'---------------------------------------------

If your files are larger than 64k or so, you'll have to read in the data in
chunks and print it.  Of course, this doesn't do any kind of formatting on
the text being printed.  That's a whole 'nuther ballgame.

--
Robert Simpson
Programmer at Large
BC Software
Phx, AZ

http://www.primenet.com/~simpson



Fri, 11 Jun 1999 03:00:00 GMT  
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR


Quote:
>does anyone kno any command or method or anything that will enable me to
>rpint text files directly.

>for example, say you store data in test.txt. you press a button, and
>voila, the printer is activated printing the file.

>Keyur Patel
>Houston, TX

Open the file, then....

Do While Not EOF(1)
        Line Input #1, t$
        Printer.Print t$
Loop

Close the file

HTH,
Ed Phillippe



Fri, 11 Jun 1999 03:00:00 GMT  
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR

Quote:



> > does anyone kno any command or method or anything that will enable me to
> > rpint text files directly.

> > for example, say you store data in test.txt. you press a button, and
> > voila, the printer is activated printing the file.

> Uhh...that's really REALLY easy...you should read the helpfiles thoroughly
> before you ask questions like this.

Good grief....Now there is someone who can't remember what it's like to
be starting out.

Quote:

> '---------------------------------------------
> x = FreeFile
> Open "test.txt" For Input As x
>   s$ = Input$(Lof(x),x)
> Close x

> Printer.Print s$;
> Printer.EndDoc
> '---------------------------------------------

> If your files are larger than 64k or so, you'll have to read in the data in
> chunks and print it.  Of course, this doesn't do any kind of formatting on
> the text being printed.  That's a whole 'nuther ballgame.

If you've got some formatted text use OLE to load the text into any
object that knows how to print it e.g. Word and tell the other app to
print it.
It'll save you loads of hassle

Regards
        Ben "Glad to help" Taylor

--
My opinions are not necessarily those of Parallax Solutions

"Things that go away on their own, come back on their own"
 - Tip of the day, Visual C++ 4



Fri, 11 Jun 1999 03:00:00 GMT  
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR



Quote:



> > > does anyone kno any command or method or anything that will enable me
to
> > > rpint text files directly.

> > > for example, say you store data in test.txt. you press a button, and
> > > voila, the printer is activated printing the file.

> > Uhh...that's really REALLY easy...you should read the helpfiles
thoroughly
> > before you ask questions like this.

> Good grief....Now there is someone who can't remember what it's like to
> be starting out.

Well do I remember how things were when I started out, which is why I did
not sling any mud. I simply mentioned that this kind of basic information
is already available in the Visual Basic helpfiles -- and provided a
simple-to-follow answer to his question.

--
Robert Simpson
Programmer at Large
BC Software
Phx, AZ

http://www.primenet.com/~simpson



Fri, 11 Jun 1999 03:00:00 GMT  
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR


Quote:
>does anyone kno any command or method or anything that will enable me to
>rpint text files directly.
>for example, say you store data in test.txt. you press a button, and
>voila, the printer is activated printing the file.
>Keyur Patel
>Houston, TX

Just guessing... but isn't it as simple as having the file sent to PRN
device? In dos you would write "copy text.txt PRN" or
"type tetx.txt >PRN"  or something, like that, can't you just use
shell to do the same?

Hope this helps

Alex


------
System report? RAM is ramming, electrons zinging.
All  systems go - or already gone.



Fri, 18 Jun 1999 03:00:00 GMT  
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR

Ok, I ripped this out of a piece of code I am working on.  It will
allow you to print any text file to printer pn$.  Parts of it were
stolen from the Helpfile but I can't remember where.

-DiscoStu

("Hey, Disco Stu doesn't advertise!")

    Final.MousePointer = 4    ' I think 4 is the hourglass
    Open "C:\MyFile" For Input As #1
    pn$ = "LPT1:"

        Dim X As Printer

        For Each X In Printers
            If X.Port = pn$ Then
                Set Printer = X
                Exit For
            End If
        Next

    Do While Not EOF(1)
        MyChar = Input(1, #1)
        Printer.Print MyChar;
    Loop
    Close
    Printer.EndDoc
    Final.MousePointer = 0      '0 is default pointer



Fri, 18 Jun 1999 03:00:00 GMT  
 HOW DO A PRINT A TEXT FILE DIRECTLY TO THE PRINTER W/O AN EDITOR

Quote:

>does anyone know any command or method or anything that will enable me to
>rpint text files directly.

This code let's the user choose a file, and then sends it to the
parallel printer port.

Sub PrintTextFile_Click ()
    Dim DefaultFileName As String   ' Default filename for file dialog.
    Dim unwanted As Integer         ' For the unused return value of the WinExec function.
    Dim CommandLine As String       ' Build a DOS command line in this string.
    Dim Response As Integer         ' For Msgbox return value.

    DefaultFileName = "*.*"

    ' "Directory" is a global variable for the app's current working directory.
    CMDialog1.InitDir = Directory

    CMDialog1.DialogTitle = "Select a text file to print"
    CMDialog1.Filename = DefaultFileName

    ' Set filters.
    CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"

    ' Specify default filter.
    CMDialog1.FilterIndex = 1

    ' Display the File Open dialog.
    CMDialog1.Action = 1

    ' Do nothing if the user cancels the dialog without selecting a file.
    If CMDialog1.Filename = DefaultFileName Then Exit Sub

    ' If a file was selected, get confirmation from the user before printing.
    Response = MsgBox("Copy " + CMDialog1.Filename + " to the printer port?", 33)
    If Response = 2 Then Exit Sub

    ' Compose a DOS command line.
    CommandLine = "copy " + CMDialog1.Filename + " lpt1:"
    ' Execute the DOS command.
    unwanted = WinExec("command.com /c " + CommandLine, SW_SHOWMINIMIZED)

End Sub

Regards
John



Sat, 19 Jun 1999 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Printing Formatted Text Directly to Printer - Help!

2. Printing PCL/5 files directly to HP Printers (VB4)

3. Printing PCL/5 files directly to HP Printers (VB4)

4. Printing directly to printer w/o using Print Manager

5. Print directly to the printer

6. print directly to win2k printer share?

7. Printing Directly to Printer

8. Printing directly to a printer

9. How to print directly to printer?

10. Printing directly to a printer from VB.

11. Printing Directly to LPT1 avoiding the printer object.

12. How to print directly to the printer?

 

 
Powered by phpBB® Forum Software