Board index » delphi » "The RPC server is unavailable" with Word 97/SP2

"The RPC server is unavailable" with Word 97/SP2

I have a coworker who has a Delphi 5 test app with a TWordApplication and a
TButton on the main form.  The button's OnClick event is coded like this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  WordApplication1.Connect;
  WordApplication1.Visible := True;
end;

Run the app, and click the button.  Word starts up.  Close Word and click
the button again.  With the original release of Word 97, Word starts up
again.  With Word 97/Service Pack 2, an exception "The RPC server is
unavailable" is thrown.

Any ideas?

-Eric Harmon

 

Re:"The RPC server is unavailable" with Word 97/SP2


My coworker has hacked around this by forcing a Disconnect before a Connect,
like this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  WordApplication1.Disconnect;
  WordApplication1.Connect;
  WordApplication1.Visible := True;
end;

This works fine, and the Disconnect call doesn't close Word or anything else
detrimental.  I'm just trying to get some sense of whether this is a bug or
a feature (Word 2000 appears to exhibit the same behavior as Word 97/SP2, so
I guess it's a feature).

-Eric Harmon

Re:"The RPC server is unavailable" with Word 97/SP2


You should wrap the disconnect with a try block.  Disconnect can fail and if
that is the case, you are no better off than you were before.

Paul

Eric Harmon [TPX] <Eric.Har...@tpx.turbopower.com> wrote in message
news:7vq8jm$gm421@forums.borland.com...

Quote
> My coworker has hacked around this by forcing a Disconnect before a
Connect,
> like this:

> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   WordApplication1.Disconnect;
>   WordApplication1.Connect;
>   WordApplication1.Visible := True;
> end;

> This works fine, and the Disconnect call doesn't close Word or anything
else
> detrimental.  I'm just trying to get some sense of whether this is a bug
or
> a feature (Word 2000 appears to exhibit the same behavior as Word 97/SP2,
so
> I guess it's a feature).

> -Eric Harmon

Re:"The RPC server is unavailable" with Word 97/SP2


Paul,

Quote
> You should wrap the disconnect with a try block.  Disconnect can fail and
if
> that is the case, you are no better off than you were before.

Will do.  My first reaction was to tell him to wrap the Connect in a try
block, and if it failed, Disconnect and then Connect.  However, the
following code:

try
  WordApplication1.Connect;
except
  ShowMessage('Error connecting');
end;

does not enter the except block.  Instead, the exception is raised.

-Eric

Other Threads