Results 1 to 5 of 5

Thread: Set PrintToFile in code

  1. #1
    pica77
    Guest

    Set PrintToFile in code

    Hello,
    I have a VB app that saves a print file by writing to a printer which is defined as a "Save to File" printer. Windows always displays a dialog box that asks the user to enter the directory to save to and the file name. Is there an API (or any other way) to set the directory and file name in the code and suppress the dialog box?
    Thanks,

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    What kind of file is the "print file"? If it is straight ASCII text, then the garden varitey OPEN yada yada will allow you to specify where, and how, the file is saved.

  3. #3
    pica77
    Guest
    It's a PostScript file. To create the PostScript file I setup a Printer using a PostScript driver and with the port set as "Print to File". In my VB code I then select that printer and write to it using Printer.Print statements. When I answer the "Print to File" dialog box the file is automatically saved as PostScript. If anyone knows a different way to create a PostScript file that would probably also solve my problem.

  4. #4
    New Member
    Join Date
    Jun 2003
    Location
    Auckland, New Zealand
    Posts
    3
    Did anyone find out how to programmatically enter in the folder and file name when this happens?
    I'm sorry but it works on my machine!

  5. #5
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    something I said a while ago...
    )Set your default postscript driver to print to a port that is set to be a default file. Note: This is different then having it set to Print To File. You don't get a nasty Popup asking for a final path. instead it just automatically prints to an individual default file, overwriting it if it already exists. See the attachment on how to set it up
    If you set your Print to File printer to print to a local port, defined as a specific Filename, then you have complete control.

    Just remove whatever old version of the file is existing before you print to the printer. Then, after you've started printing, Monitor the file and the printer. If you can detect when the printer has finished, then check when the file is not locked, then you can move it, name it anything you want.


    BTW, Attached is an old zip file showing how to add a File as a port to an existing printer on Win 98. Its pretty easy on 2000, and I suspect you'll figure it out with whatever version you're useing.

    -Lou
    Attached Files Attached Files

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