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!

Print a .TXT file

Status
Not open for further replies.

stroker1

Programmer
Dec 16, 2004
1
US
I have had success printing a text file in VB such as follows:

Public Sub Printtxtfile(filename as string)
Dim s as string
Open filename for input as #1
printer.font = "courier"
printer.fontsize = 12
line input #1,s
printer.print s
loop
...
I have yet to find a way to pass a variable (filename) to vbscript and get it to print.
Here is what I have tried with no success:

Public Sub Printtxtfile (filename as string)
Shell("notepad /p " + filename)
end sub

Any suggestions!!!! Thanks in advance
 
Just realised I was in the VBScript page... Sorry. Ignore my above comments.
 
This should be more what you are looking for:

Code:
Set Shell = WScript.CreateObject("WScript.Shell")

Sub Printtxtfile(filename)
Shell.Run "Notepad /p " & filename
End Sub

Spong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top