J
John
Hi
I am using the code given at the end to open a word document from within
vb.net. It works fine the first time but the second time I get the error;
Unhandled Exception: System.Runtime.InteropServices.COMException
(0x800706BA): The RPC server is unavailable.
at Word.ApplicationClass.get_Documents()
The error occurs on the line WordDoc = WordApp.Documents.Add(<Template
name>)
Any idea what I am doing wrong? Surprisingly, if I open a backup copy of the
project (with the same code as far as I can see), it works! Does this mean
something has gone corrupt?
Thanks
Regards
= Code Follows ==================
Public Class clsOfficeWrapper
Private WithEvents WordApp As Word.Application
Private WithEvents WordDoc As Word.Document
Public Sub NewFax(ByVal Temp As String)
If WordApp Is Nothing Then
WordApp = New Word.Application
WordApp.Options.ShowControlCharacters = False
End If
WordDoc = WordApp.Documents.Add(Temp) '<== This lines gives error, the
second time round
With WordDoc
.ActiveWindow.Visible = True
End With
WordApp.Activate()
WordDoc = Nothing ' Kill the refernce only - not the document itself
End Sub
....
End Class
I am using the code given at the end to open a word document from within
vb.net. It works fine the first time but the second time I get the error;
Unhandled Exception: System.Runtime.InteropServices.COMException
(0x800706BA): The RPC server is unavailable.
at Word.ApplicationClass.get_Documents()
The error occurs on the line WordDoc = WordApp.Documents.Add(<Template
name>)
Any idea what I am doing wrong? Surprisingly, if I open a backup copy of the
project (with the same code as far as I can see), it works! Does this mean
something has gone corrupt?
Thanks
Regards
= Code Follows ==================
Public Class clsOfficeWrapper
Private WithEvents WordApp As Word.Application
Private WithEvents WordDoc As Word.Document
Public Sub NewFax(ByVal Temp As String)
If WordApp Is Nothing Then
WordApp = New Word.Application
WordApp.Options.ShowControlCharacters = False
End If
WordDoc = WordApp.Documents.Add(Temp) '<== This lines gives error, the
second time round
With WordDoc
.ActiveWindow.Visible = True
End With
WordApp.Activate()
WordDoc = Nothing ' Kill the refernce only - not the document itself
End Sub
....
End Class