|
-
Oct 24th, 2001, 03:32 AM
#1
Thread Starter
Hyperactive Member
sending documents to the printer
I need to write a program that checks a directory every couple of seconds and if a text file has been dumped into it. If so this text file needs to be sent to the printer and printed out as hard copy.
What are the commands for sending a whole file / document to the printer. And is there a free ware program that already does this ( ie polling a named dir for documents to reprint ) after theres no point in reinventing the wheel.
Thanks
-
Oct 24th, 2001, 04:37 AM
#2
-= B u g S l a y e r =-
I wrote the prog for u 
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim sFileName As String
Dim sFullFilename As String
Dim sTextFilePath As String
Dim sBackPath As String
Dim s As String
sTextFilePath = "C:\TEXTFILES"
sBackPath = sTextFilePath & "\bak"
While Dir(sTextFilePath & "\*.TXT") <> ""
sFileName = Dir(sTextFilePath & "\*.TXT")
sFullFilename = sTextFilePath & "\" & sFileName
s = GetFileContents(sFullFilename)
Printer.Print s
If Dir(sBackPath, vbDirectory) = "" Then MkDir sBackPath
FileCopy sFullFilename, sBackPath & "\" & sFileName
Kill sFullFilename
Wend
End Sub
Private Function GetFileContents(fileName As String) As String
If Dir(fileName) <> "" Then
Open fileName For Binary As #1
GetFileContents = Input(LOF(1), 1)
Close #1
End If
End Function
just move the code in the command button to a Timer.
-
Oct 24th, 2001, 04:41 AM
#3
-= B u g S l a y e r =-
oops
hi again, just realized, this will print all the files as one doc... add this line :
after the
-
Oct 24th, 2001, 06:28 AM
#4
Thread Starter
Hyperactive Member
thanx a lot
cheers m8 , thats just what I was after.
Much appreciated
-
Oct 24th, 2001, 06:47 AM
#5
-= B u g S l a y e r =-
good 
let me know if u get into any problems with it .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|