Word Automation RPC Server is unavailable 
Author Message
 Word Automation RPC Server is unavailable

I have pared down the code to its minimum to create the error.  When
it errors it errors on the .Section.ParagraphFormat....   Code will
run fine first time.  It will also run repeatedly once it fails and
you choose end for Word is running.  It will also run repeatedly if
you open word first then run the code multiple times.  If you have any
insight I would greatly appreciate it.

Public Sub Tryit()
    Dim objWord As Word.Application
    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True
    With objWord
            .Documents.Add
            'page setup
            .Selection.ParagraphFormat.TabStops.Add
Position:=InchesToPoints(0.5), _
                Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
    End With
    objWord.Quit SaveChanges:=wdDoNotSaveChanges
    Set objWord = Nothing
End Sub



Tue, 03 May 2005 02:38:42 GMT  
 Word Automation RPC Server is unavailable
Try these 2 things:

a) Set a reference to the document you are adding instead of depending on it
being the default doc open.

b) Call ".Select" first before working with the Selection object.

 -- Dev


Quote:
> I have pared down the code to its minimum to create the error.  When
> it errors it errors on the .Section.ParagraphFormat....   Code will
> run fine first time.  It will also run repeatedly once it fails and
> you choose end for Word is running.  It will also run repeatedly if
> you open word first then run the code multiple times.  If you have any
> insight I would greatly appreciate it.

> Public Sub Tryit()
>     Dim objWord As Word.Application
>     Set objWord = CreateObject("Word.Application")
>     objWord.Visible = True
>     With objWord
>             .Documents.Add
>             'page setup
>             .Selection.ParagraphFormat.TabStops.Add
> Position:=InchesToPoints(0.5), _
>                 Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
>     End With
>     objWord.Quit SaveChanges:=wdDoNotSaveChanges
>     Set objWord = Nothing
> End Sub



Tue, 03 May 2005 05:17:47 GMT  
 Word Automation RPC Server is unavailable
I found the solution to the issue I was having on Microsoft's website.

http://support.microsoft.com/default.aspx?scid=KB;en-us;q189618

Visual Basic has established a reference to Word due to a line of code
that calls a Word object, method, or property without qualifying it
with a Word object variable. Visual Basic does not release this
reference until you end the program. This errant reference interferes
with automation code when the code is run more than once.

In the position section of the tabstops I referenced InchesToPoints
without referencing the word object that I declared.  When I changed
this to objWord.InchesToPoints everything works as it is supposed to.

Quote:

> Try these 2 things:

> a) Set a reference to the document you are adding instead of depending on it
> being the default doc open.

> b) Call ".Select" first before working with the Selection object.

>  -- Dev



> > I have pared down the code to its minimum to create the error.  When
> > it errors it errors on the .Section.ParagraphFormat....   Code will
> > run fine first time.  It will also run repeatedly once it fails and
> > you choose end for Word is running.  It will also run repeatedly if
> > you open word first then run the code multiple times.  If you have any
> > insight I would greatly appreciate it.

> > Public Sub Tryit()
> >     Dim objWord As Word.Application
> >     Set objWord = CreateObject("Word.Application")
> >     objWord.Visible = True
> >     With objWord
> >             .Documents.Add
> >             'page setup
> >             .Selection.ParagraphFormat.TabStops.Add
> > Position:=InchesToPoints(0.5), _
> >                 Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
> >     End With
> >     objWord.Quit SaveChanges:=wdDoNotSaveChanges
> >     Set objWord = Nothing
> > End Sub



Tue, 03 May 2005 23:40:03 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Automation Error/The RPC Server is unavailable with Access/Word97

2. The RPC Server is Unavailable

3. RPC server is unavailable Error

4. RPC Server unavailable...

5. RPC Server is unavailable

6. RPC server unavailable (Office 97)

7. RPC Server is Unavailable

8. Help on "RPC Server unavailable" error

9. The RPC server is unavailable.

10. Error: "The RPC Server is Unavailable"

11. Error: "The RPC Server is Unavailable"

12. RPC server unavailable or not responding

 

 
Powered by phpBB® Forum Software