Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i automatically print a text file from vb without opening it

Status
Not open for further replies.

2314

Programmer
May 19, 2001
69
IN
how do i automatically print a text file from vb without opening it
 
Just shell to a command prompt and use the Print command.

Shell ("cmd /c print c:\fred.txt")

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
You may also use ShellExecute function to print a variety of documents including text files.
___
[tt]
Private Declare Function ShellExecute Lib "shell32" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub PrintDocument(Document As String)
ShellExecute hwnd, "print", Document, "", "", 0
End Sub
Private Sub Form_Load()
PrintDocument "C:\fred.txt"
End Sub[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top