Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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"?
Posted

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

  • *Experts*
Posted

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

Printer Monitor for .NET? - see Merrion Computing Ltd for details

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...