• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Print to file

I am trying to print a document to a file instead of to the printer using VB5.  I tried the "print#1" route, but keep getting file already open, even though I'm using a different file with a different name, etc.  Is there another way I can print a printer document to a file?
1 Solution
See if this helps.
The file # your using should not be a constat.
Use FreeFile function to get the free file # and try printing the file.
This seemed a little unclear to me even though I know what Bhargava was trying to say. Try following these steps:

1. Declare a variable as an integer

2. Assign a valid file handle to that variable by calling:
 (variable) = FreeFile

Don't forget to open, close, and print using only this file handle, and that each file handle may only be used for one open file. To open multiple files, you will need to get multiple free file handles...

 let printer document be file_tobe_printed .
you can use following code:

      open file_tobe_printed For Binary As #num1
      open new_file For BInary As #num2
      while( Not EOF(num1))
          get  #num1, ,Chunk
          put #num2, .Chumk
      Close #num2
      Close #num1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now