
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