bmilne
asked on
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
let printer document be file_tobe_printed .
you can use following code:
num1=FreeFile
open file_tobe_printed For Binary As #num1
num2=FreeFile
open new_file For BInary As #num2
while( Not EOF(num1))
get #num1, ,Chunk
put #num2, .Chumk
wend
Close #num2
Close #num1
you can use following code:
num1=FreeFile
open file_tobe_printed For Binary As #num1
num2=FreeFile
open new_file For BInary As #num2
while( Not EOF(num1))
get #num1, ,Chunk
put #num2, .Chumk
wend
Close #num2
Close #num1
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...
Singe