By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,008 Members | 2,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,008 IT Pros & Developers. It's quick & easy.

how to print multiple word documents via vb.net

P: n/a
I'd like to be able to print multiple documents are once using vb.net.
What is the best way to do this with out having to print each document
one at a time via a loop [calling
Word.PrintOut(fileName:=(OutputFileLocation & fileName)].

Can't I send them all to a spool at once or something?

Ideally, I would like the code such that multiple users can print via
my application at the same time.

Any help would be appreciated. Thanks

8957078

PS

Someone suggested merging the docs into one programatically but i'm
not sure if that would solve the problem i'm having with the printing
getting locked up when users try to print at the same time.

If this is a good idea, does anyone have any examples?
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi 8957078,

Unusual handle you've got there! ;-)

I think <your program> is going to have to be that spooler.

What's the objection to looping through your Word.Prints? If it's because
your app can't do anything until all the printing is done, then I would
suggest learning just how easy** it can be to do it in a separate Thread.

When you say 'multiple users ... at the same time', what do you mean,
exactly?

Regards,
Fergus

** 'easy' - a relative term, but I would hope that you'd be nicely surprised.
:-)
Jul 21 '05 #2

P: n/a
Below is my code. The object I loop through is an array of documents
data (holds paths and filenames of docs to be printed).

I'm using InterOp. It seems to lock up and never print if two or more
users try to print the same documents.

In any case, do you have an example of doing the multi thread for this
situation?
Thanks for your input.

8957078
----------------------------------------------------------------
Try
MergeDocumentAndPrint(documents, aDocumentInformation)

''Original Code Below
'If Not documents Is Nothing AndAlso documents.Count > 0
Then
' m_Word = CreateObject("Word.Application")
'Start Word and open the document template.
' m_Word.Visible = False
'Have Word run in background

' We have some files, Print Them
For Each aDocumentInformation In documents
If Not
aDocumentInformation.EndorsementLongDescription = (New
BOConstants).QUOTE_SHEET_NAME Then

Me.PrintDocument(aDocumentInformation.FileName)
End If
Next
Me.CloseWinWord() 'Clean Up
End If
Catch ex As Exception
Me.CloseWinWord()
Me.CreatePrintingException("The following error received
while attempting to print a document: " & _
ex.ToString)
End Try
----------------------------------------------------------------

"Fergus Cooney" <fi******@tesco.net> wrote in message news:<#e**************@TK2MSFTNGP10.phx.gbl>...
Hi 8957078,

Unusual handle you've got there! ;-)

I think <your program> is going to have to be that spooler.

What's the objection to looping through your Word.Prints? If it's because
your app can't do anything until all the printing is done, then I would
suggest learning just how easy** it can be to do it in a separate Thread.

When you say 'multiple users ... at the same time', what do you mean,
exactly?

Regards,
Fergus

** 'easy' - a relative term, but I would hope that you'd be nicely surprised.
:-)

Jul 21 '05 #3

P: n/a
Hi SpamProof,
I'm using InterOp. It seems to lock up and never print if two or more
users try to print the same documents.

The problem you're running into is inherent to Word: Word puts a file
lock on opened documents because it doesn't support any kind of file
sharing.

My suggestion would be to have your program create a COPY of the
document (at the file level), open that, print it. And when the print
process is finished, delete all the copies.

-- Cindy

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.