Results 1 to 5 of 5

Thread: sending documents to the printer

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    UK
    Posts
    300

    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
    Resistance is futile

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    I wrote the prog for u

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim sFileName As String
    5.     Dim sFullFilename As String
    6.     Dim sTextFilePath As String
    7.     Dim sBackPath As String
    8.     Dim s As String
    9.    
    10.     sTextFilePath = "C:\TEXTFILES"
    11.     sBackPath = sTextFilePath & "\bak"
    12.  
    13.     While Dir(sTextFilePath & "\*.TXT") <> ""
    14.         sFileName = Dir(sTextFilePath & "\*.TXT")
    15.         sFullFilename = sTextFilePath & "\" & sFileName
    16.         s = GetFileContents(sFullFilename)
    17.         Printer.Print s
    18.         If Dir(sBackPath, vbDirectory) = "" Then MkDir sBackPath
    19.         FileCopy sFullFilename, sBackPath & "\" & sFileName
    20.         Kill sFullFilename
    21.     Wend
    22. End Sub
    23. Private Function GetFileContents(fileName As String) As String
    24.     If Dir(fileName) <> "" Then
    25.         Open fileName For Binary As #1
    26.             GetFileContents = Input(LOF(1), 1)
    27.         Close #1
    28.     End If
    29. End Function

    just move the code in the command button to a Timer.
    -= a peet post =-

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    oops

    hi again, just realized, this will print all the files as one doc... add this line :

    VB Code:
    1. Printer.EndDoc

    after the

    VB Code:
    1. Printer.Print s

    -= a peet post =-

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    UK
    Posts
    300

    thanx a lot

    cheers m8 , thats just what I was after.
    Much appreciated
    Resistance is futile

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    good

    let me know if u get into any problems with it .
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width