printing word doc

J

JFB

Hi All,
I'm printing masive word documents from a folder.
I used a vb.net app under windows 2003 server with word 2003 installed.
The problem is that winword.exe doesn't close in the task manager.
In my developer desktop using xp pro does work using wordDoc.close(false)
Now if I keep wordDoc.close(false) in win2k3 doesn't print at all, but it
does only with wordDoc.close() but keeps winword.exe for every single file.
Any body can help me with this issue?
Thanks

JFB
Here my code that works in XP
Dim NewWordApp As New Word.Application

Dim NewWordDoc As New Word.Document

Dim ps As New Printing.PageSettings

Dim wfName As String

Dim fContent As String



'Create File Name

wfName = "C:\SummaryPage.doc"

'Create the instance of the objects

Try

'for office xp

NewWordApp = CreateObject("Word.Application")

NewWordDoc = CreateObject("Word.document")

Catch

'for office 2000 and 97

NewWordApp = New Word.Application

NewWordDoc = New Word.Document

End Try

NewWordApp.Visible = False

ps.PaperSource = ps.PrinterSettings.PaperSources.Item(3)

'Create File content

fContent = " some content" & vbCrLf & vbCrLf


NewWordDoc.Content.Text = fContent & vbCrLf

NewWordDoc.Content.Font.Size = 10

Try

NewWordDoc.PrintOut()

Catch ex As Exception

MessageBox.Show(ex.ToString())

End Try

NewWordDoc.SaveAs(wfName)

NewWordDoc.Close()

NewWordApp.Quit(False)

NewWordDoc = Nothing

NewWordApp = Nothing
 
S

SurturZ

I'm not 100% sure but I think you are starting two instances of MS Word.

once here:
Dim NewWordApp As New Word.Application

and again here:
NewWordApp = CreateObject("Word.Application")

If you get rid of the "New" keyword in the Dim statement, I think it will
fix the problem.
 
J

JFB

Good eye David,
That was the problem...! weird that in xp pro doesn't keep winword.exe open.
Thanks again.

JFB
 

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