Why there is error message "RPC Server is unavailable?" for accessing word

John Wen

Member
Joined
Jul 3, 2008
Messages
8
Programming Experience
1-3
Hello

When I wrote the following VB.NET codes, I encountered error message "RPC server is unavailable." How can I solve this problem?
My original intention was to display the table data inside the MS Word document (johntable.doc). Please help.
The second time I used the x (Word.Cell), "RPC server is unavailable" error comes out! The first time I used the x I can sucessfully display table data though.


VB.NET:
    Dim oWord As New Word.Application
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim x As Word.Cell = oWord.Documents.Open("c:\rubbish\johntable.doc").Content.Tables.Item(1).Cell(3, 5)
        MsgBox(x.Range.Text)

 x = oWord.Documents.Open("c:\rubbish\johntable.doc").Content.Tables.Item(1).Cell(4, 4)            [COLOR="Red"]<--second time using x[/COLOR]
        MsgBox(x.Range.Text)

    End Sub


John Wen
 
Last edited:
Try to open the document only once, and close it afterwards. Pseudo code:
doc=word.open("path")
cell=doc.content.tables...cell(3,5)
cell=doc.content.tables...cell(4,4)
doc.close
 
"RPC Server is unavailable" still exists!!

Hello
After I tried the following approach, that "RPC Server is unavailable" problem still exists. (See my code quoted as belows) Where is the problem?? Please help me do.

Regards
John Wen
21 - July - 08
====================suggested by Mr JohnH===========
'---Quote---
' doc = Word.open("path")
'cell=doc.content.tables...cell(3,5)
'cell=doc.content.tables...cell(4,4)
' doc.close()
'---End Quote---
================================================
=================same as above psuedo code===============
Dim ooWord As New Word.Application
Dim ooDoc As Word.Document
Dim mycell As Word.Cell
Dim mycell1 As Word.Cell
ooDoc = ooWord.Documents.Open("c:\Rubbish\johntable.doc")
mycell = ooDoc.Content.Tables.Item(1).Cell(3, 5)
'MsgBox(mycell.Range.Text)

mycell = ooDoc.Content.Tables.Item(1).Cell(4, 4)
MsgBox(mycell.Range.Text)
ooDoc.Close() <-- " 'RPC Server is unavailable' occurs at this line"
=======================================================
 
I can't verify the exact code at the time, but in case of RPC error make sure you are interfacing the office automation libraries with the correct version of official Primary Interop Assemblies.
 
Back
Top