printing word docs

  • Thread starter Thread starter JFB
  • Start date Start date
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
 
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.
 
Back
Top