By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

P: n/a
I am using the attached code

Private Sub StartApplicationProcess
InitialiseObject()
oWord.Visible = True
oDoc = oWord.Documents.Open(StrStackPath)
oWord.Visible = True
end sub

The variables oWord and oDoc are declared in the class as below
attached

Private WithEvents oWord As Word.Application
Private WithEvents oDoc As Word.Document

The sub InitialiseObject() has the below code

Private Sub InitialiseObject()
oWord = New Word.Application
End Sub

Ok, lets start! I am having a very strange issue. I am creating a word
document using the documents.add method and I close word using
the .Quit method, then I am calling the sub StartApplicationProcess
(shown above). On the first instance everything goes well and the
document is launch as per my requirements. However when I launch again
the document I am having The RPC server is unavailable. (Exception
from HRESULT: 0x800706BA) in line "oDoc =
oWord.Documents.Open(StrStackPath)" in sub StartApplicationProcess. I
can't understand this error since I am still initialising the object
oWord. Why he can't find the word to launch the document? Funnily
enough, if I declare the oWord and the oDoc inside the sub
StartApplicationProcess itself, I will not get the error and the
document is open, but I can't afford of declaring a local variable
since as shown above the variables are also being used to handle
events. I also tried moving the code oWord = New Word.Application from
the sub InitialiseObject to sub StartApplicationProcess but vb.net
failed again.

This is happening with office 2003.

Your suggestion will be greatly appreciated since I really don't know
how to handle this issue.

Thanks

Apr 19 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Further to this I've done so more troubleshooting and here are my
results

Noticed that the issue is coming from the variable oWord. As shown
below the variable oWord is declared at the top level of the class as
Private WithEvents oWord As Word.Application. The word docuement is
opening in a normal manner. When it is closed the event is raised and
therefore the document is closed. In the StartApplicationProcess the
code is getting stuck in the code line oDoc =
oWord.Documents.Open(StrStackPath). The rpc server is unavailable
error shows that you cannot open a document if the word application is
open. In my case the word application is open and visible, and if I
watch the oWord variable it shows that it has been defined to open. If
I change the oWord.visible = false, the word application will hide.
This is another prove that oWord variable has been assigned to the
word.application. If I execute the code oWord.Documents.add the error
RPC server is again there

If I don't trigger the odoc.close event the program will work normally
and it will not stop if I try to open the document for x amount of
times.

Do you have any ideas what's happening here?

Thanks again

ta*********@hotmail.com wrote:
I am using the attached code

Private Sub StartApplicationProcess
InitialiseObject()
oWord.Visible = True
oDoc = oWord.Documents.Open(StrStackPath)
oWord.Visible = True
end sub

The variables oWord and oDoc are declared in the class as below
attached

Private WithEvents oWord As Word.Application
Private WithEvents oDoc As Word.Document

The sub InitialiseObject() has the below code

Private Sub InitialiseObject()
oWord = New Word.Application
End Sub

Ok, lets start! I am having a very strange issue. I am creating a word
document using the documents.add method and I close word using
the .Quit method, then I am calling the sub StartApplicationProcess
(shown above). On the first instance everything goes well and the
document is launch as per my requirements. However when I launch again
the document I am having The RPC server is unavailable. (Exception
from HRESULT: 0x800706BA) in line "oDoc =
oWord.Documents.Open(StrStackPath)" in sub StartApplicationProcess. I
can't understand this error since I am still initialising the object
oWord. Why he can't find the word to launch the document? Funnily
enough, if I declare the oWord and the oDoc inside the sub
StartApplicationProcess itself, I will not get the error and the
document is open, but I can't afford of declaring a local variable
since as shown above the variables are also being used to handle
events. I also tried moving the code oWord = New Word.Application from
the sub InitialiseObject to sub StartApplicationProcess but vb.net
failed again.

This is happening with office 2003.

Your suggestion will be greatly appreciated since I really don't know
how to handle this issue.

Thanks
Apr 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.