how to print multiple word documents via vb.net

G

Guest

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?
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (SpamProof) scripsit:
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.

I would ask this question in the Word group: microsoft.public.word.vba.general.
 
F

Fergus Cooney

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.
:)
 
G

Guest

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
 
C

Cindy M -WordMVP-

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top