‘Print To File’ for Access Reports Under Software Control
Posted on 1997-12-18
I’m attempting to determine how I can print a Microsoft Access97 Report to a File strictly under software control. By that I mean to print it through a standard printer driver (such as ‘HP LaserJet 4’), but route the output to a file instead of the physical port. If all works as desired the file could later be copied to the port (e.g. COPY FILE.PRT LPT1:) to produce the final output. All of this MUST be done under program control with no user interaction.
To give you a somewhat larger picture, I have a custom application written in Visual Basic (5.0 EE) which uses Microsoft Access97 to generate a large number of reports. I am in the process of enhancing the app to interface to a FAX server back-end. My app needs to generate the files described in the previous paragraph to pass to the FAX server to image the pages to be sent over the modem/phone line.
All of the components run under Windows NT 4.0
I’ve looked at the Access97 OutputTo, but this is unsuitable, since all graphics are not rendered.
The Access97 PrintOut method seems similar to the Word97 ‘FilePrint’ method but, unlike the latter, does not support a OutputToFilename argument.
I’ve tried digging through the SDK documentation of the MSDN library regarding the DEVMODE and DEVNAMES structures, but havn’t found what I’m looking for. I’ve even tried tweaking the prtDEVNAMES structure for Access97 reports by modifying the ‘port’ member of the structure to ‘FILE:’ or the path of a file (e.g. ‘C:\TEST\TEST.PRN’) with no luck. I’ve done similar things with a printer installed which uses the ‘FILE:’ port (which would be ok if it didn’t throw-up a dialog asking the user for a file name!)
As I said earlier, all functionality must be controllable within software – solutions which rely, for example, on a user entering text (i.e. a filename) into a dialog box will not fly.
Got any suggestions?