RPC Server Unavailable

Mark Hammond MarkH at ActiveState.com
Sun Jun 10 01:31:36 EDT 2001


Matthew Turk wrote:

> For instance - I call a Word Dispatch.  I open a document, then make
> it visible.  The user does whatever, then closes either the document
> or the application - either way, it returns to the python app.  At
> that point, how can I tell if the user minimized, closed, or what, the
> application?  I'll be doing the same thign with Excel, and up until
> now I've had good luck with a DispatchDict I experimented with, but
> Word seems to complicate the matter, as does closing an Excel

> document.


You could try hooking the Excel and Word events.  Check out the examples 
in the win32com\test directory - Word and Excel are specifically tested 
in testMSOfficeEvents.py.  You will probably want to consult the Office 
docs or peruse the makepy generated file to see what events are available.

> Anyway, the error I get is "RPC Server Unavailable."  And a summary of
> my question - how can I tell if a dispatch, stuck in a variable, is
> still active?


In the general case tho, you really have no alternative other than to 
catch the exception.  Try doing something free from side-effects - such 
as querying the current value of the "visible" property.

You probably should do this even if you can hook the events you are 
after - Word or Excel could simply die with an Access Violation, and in 
that case there is almost certainly no event that will tell you that...

Mark.




More information about the Python-list mailing list