P
Phil Galey
I'm trying to automate MS Word 9 on Windows 2000 from VB.NET. I'm using the
following code:
Dim TmpltPath As String = Path.Combine(Application.StartupPath,
"SpanishForm.doc")
Dim pcss(), pcs As Process
Dim WDoc As Word.Document
Dim WApp As Word.Application
If Process.GetProcessesByName("WINWORD").Length = 0 Then
Process.Start(mstrWord)
Threading.Thread.Sleep(3000)
End If
WDoc = New Word.Document() <=== Interop COM Exception: Call was
rejected by callee.
WApp = WDoc.Application
WApp.Documents.Close(False)
WApp.Documents.Open(strDocPath)
but about 50% of the time, it errors out as indicated above. How can I
dependably instantiate a new Word.Document object without getting this
error? Thanks.
following code:
Dim TmpltPath As String = Path.Combine(Application.StartupPath,
"SpanishForm.doc")
Dim pcss(), pcs As Process
Dim WDoc As Word.Document
Dim WApp As Word.Application
If Process.GetProcessesByName("WINWORD").Length = 0 Then
Process.Start(mstrWord)
Threading.Thread.Sleep(3000)
End If
WDoc = New Word.Document() <=== Interop COM Exception: Call was
rejected by callee.
WApp = WDoc.Application
WApp.Documents.Close(False)
WApp.Documents.Open(strDocPath)
but about 50% of the time, it errors out as indicated above. How can I
dependably instantiate a new Word.Document object without getting this
error? Thanks.