MRCP Posted August 25, 2003 Posted August 25, 2003 I hope this is the right place to post this. I am a beginner with VB.Net and hope someone can help me with this question. Building a program in which I want to be able to access and print pre-existing text files (created with Wordpad). From the VB.Net books I have been reading, seems like the easiest way to do this is to use the "Process" component from the Components tab of the Toolbox. Indeed, I have been able to make my program open a blank Wordpad window, but unable to make it open or recognize my pre-existing files. I have ensured that my file pathways are correct, but keep getting an error message saying my file path is not recognized. I am attempting to print files from a Collection created by my program. Via debugging I have confirmed that the For Each...Next loop I am using to process the collection is working just fine. The code is like this: Public PMHName As String Public PMHFormsColl As New Collection (then intervening code to assemble the collection, which consists of variables declared as strings and assigned specific file pathways) I then use the Components tab to add a "Process" component to the form(which I name "mdprint") For Each PMHName in PMHFormsColl mdprint.Start() Next PMHName This opens a blank Wordpad window. If I make it mdprint.Start(PMHName) I get the error message. Sorry for the long post. I am totally jammed on this, any help will be much appreciated! Thanks, MRC Quote
MRCP Posted August 26, 2003 Author Posted August 26, 2003 I am responding to my own post to clarify. Just spent several more hours going through my VB books and several online VB.Net forums. It appears printing stuff with VB.Net is quite a handful as near as I can tell. It seems even to print a pre-existing text file will require great quantities of code defining just about every imaginable aspect of a document. This is quite depressing as it appears far beyond my ability to accomplish. So now just looking to confirm this as the reality of the situation so I do not waste more time trying to make it work! Are there any alternatives to "Print Document" or "Print Page"? Quote
aewarnick Posted August 26, 2003 Posted August 26, 2003 I don't think so, unless you want to pay for a printing class. Quote C#
*Experts* Merrion Posted August 26, 2003 *Experts* Posted August 26, 2003 You can get Notepad to do the printing for you to the default printer using the ShellExecute API call and passing "print" in the fCommand parameter. Quote Printer Monitor for .NET? - see Merrion Computing Ltd for details
*Gurus* divil Posted August 26, 2003 *Gurus* Posted August 26, 2003 The ShellExecute API is partly what the Process class wraps - you can pass the "print" open action to a file using it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
MRCP Posted August 26, 2003 Author Posted August 26, 2003 Thanks for the feedback about my problem. Will ShellExecute work in VB.Net,though? I read about it on another forum and was under the impression it was a VB6 command. If it will work, can you post a sample of the syntax I should use as well? Thanks! MRC Quote
*Experts* Merrion Posted August 27, 2003 *Experts* Posted August 27, 2003 Use the Process class, as Divil says.... Dim foo As New System.Diagnostics.Process() For Each PMHName in PMHFormsColl foo.StartInfo.Filename = PMHName foo.StartInfo.Verb = "print" '<-- Cause the file to be printed... foo.Start() '<-- Kick off the process... Next Quote Printer Monitor for .NET? - see Merrion Computing Ltd for details
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.