printing word docs

J

JFB

Hello All,
I'm printing word docs using this code in a loop of many documents.
'Start Loop

'Create word App and document

Dim wordApp As Word.Application

Dim wordDoc As Word.Document

'Create the instance of the word document

wordApp = CreateObject("Word.Application")

wordDoc = CreateObject("Word.document")

wordApp.Visible = False

wordDoc = wordApp.Documents.Open(fileName:=docName.ToString)



wordDoc.PrintOut()

'close Word App and kill object

wordDoc.Close()

wordApp.Quit()

wordDoc = Nothing

wordApp = Nothing

'end loop

When I print more than 500 documents my windows 2003 server use 100% of CPU
and only 320mb of memory, doing the print very slow.

The app was in vs 2000 without any issues, I move to vs 2005 and now I have
this problem.

Any ideas how can I improve this? maybe a better way to print word docs.

Thanks in advance.

JFB
 
F

Family Tree Mike

JFB said:
Hello All,
I'm printing word docs using this code in a loop of many documents.
'Start Loop

'Create word App and document

Dim wordApp As Word.Application

Dim wordDoc As Word.Document

'Create the instance of the word document

wordApp = CreateObject("Word.Application")

wordDoc = CreateObject("Word.document")

wordApp.Visible = False

wordDoc = wordApp.Documents.Open(fileName:=docName.ToString)



wordDoc.PrintOut()

'close Word App and kill object

wordDoc.Close()

wordApp.Quit()

wordDoc = Nothing

wordApp = Nothing

'end loop

When I print more than 500 documents my windows 2003 server use 100% of CPU
and only 320mb of memory, doing the print very slow.

The app was in vs 2000 without any issues, I move to vs 2005 and now I have
this problem.

Any ideas how can I improve this? maybe a better way to print word docs.

Thanks in advance.

JFB

I don't know that this will be "better", but you could try using
System.Diagnostics.Process using the word file as the filename, and
print as the verb. That way, each print will be a separate process, and
should reduce your process use.
 
J

JFB

Thanks for you reply and help.
Never use process before.
Do you have a link or sample?
Rgds
 

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