Tips & Tricks #0004
I recently received an email from a reader who wanted to print the contents of his Visual Basic project to a file.
For those of you not familiar with this Print feature of Visual Basic, you can print an image of any or all of the forms in your Visual Basic project, plus the code in those forms, to a printer for documentation purposes.
In addition to printing directly to a printer, you can also route the print to a text file---either for archive purposes or for subsequent printing.
The problem is that when my reader tried to view the output file using his Notepad Editor, he reported seeing strange characters at the top of the document, and when he printed the file from within Notepad, the results were far from satisfactory.
What causes this is that when he directed the print output to a file, his Windows default printer was set to a high tech model (either a laser or an ink jet printer). The strange characters included in the document were printer control characters that Windows inserted into the file---the same characters that Windows would have sent to the default printer to ensure that the document printed properly..
Fortunately, the fix is easy.
To produce a file that can then be opened cleanly in an editor such as Notepad, you must first install a Generic-Text Only Printer driver on your system (You can do this by Adding a Generic-Text Only Printer via the Windows Print Manager), and then selecting this Printer as the target printer in the VB Printer Dialog Box.
The result is that your output file will contain only text---no special Printer Control Characters.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment