
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