CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Location
    India
    Posts
    173

    Silly, Print Help

    I have a Txt file a.txt in c:

    I want to take the print out of the file through DOs something like c:\a.txt > prn

    I don't want any windows print out becaues it is too slow.

    I am doing something like this :

    a = Shell("cmd.exe")
    SendKeys "Type C:\dirbat.txt >prn"


    This opens too many dos prompts and there is no result at end.

    I need this urgently,

    Thanks,
    Shivakumar G.M.


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Silly, Print Help

    Maybe this can help, instead of sending the file to the printer, send the file to a .prn file, then shell a batch file that sends that file to the printer. Sending a .prn file to a printer can be done using copy, like this

    copy output.prn LPT1
    or
    copy output.prn \\SomeServer\SomeSharedPrinter

    This however requires that the file is printed to a file using the printer API's, like when you select the checkbox 'print to file' in the common dialog.


    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Sep 2001
    Location
    Little Rock, Arkansas
    Posts
    40

    Re: Silly, Print Help

    Would something like this work?

    Open "C:\Print.bat" For Output As #1
    Print #1, "Type C:\dirbat.txt > prn"
    Close #1
    Shell "C:\Print.bat", vbHide



  4. #4
    Join Date
    Aug 2001
    Location
    India
    Posts
    173

    Re: Silly, Print Help

    Thanks a lot, it works great.

    sir, what I had done right now was, I made a EXE file in C which accepts a command line argument that is the name of the file like
    shell("printMe a.txt")

    The c file internally gives a command like
    system("Type a.txt > PRN")


    Your example works fine.

    Thanks.
    Shivakumar G.M.


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

Featured