Solved

Print to file

Posted on 1998-12-07
3
161 Views
Last Modified: 2010-05-03
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?
0
Comment
Question by:bmilne
3 Comments
 
LVL 2

Accepted Solution

by:
Bhargava earned 50 total points
ID: 1448594
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.
0
 

Expert Comment

by:singe
ID: 1448595
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...

Singe
0
 

Expert Comment

by:swathi
ID: 1448596
 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
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now