Passing object as param to Python COM server

Graham Fawcett gmfawcett at operamail.com
Wed Nov 7 19:31:37 CET 2001


Hi folks,

I've got a COM server written in Python, and it's running great (thank you to 
EVERYONE who made this marvellous tech possible). But I've got a question 
about passing parameters in method calls on my server.

I have a VB script in PowerPoint that creates an instance of my server. I'd 
like to pass a reference to the PowerPoint application to my server, for 
example:

'in the PowerPoint macro,
sub PassExample(pptapp as Application)
  Set myserver = CreateObject("UWindsor.MyServer")
  myserver.QueryApp pttapp 
end sub

# in the server,
def QueryApp(self, app):
  #Name should be a valid attribute of a PowerPoint.Application
  print app.Name
  ...

Running the VB macro incurs an AttributeError: Name when the QueryApp method 
is called.

The object (app) passed to my server is a PyIDispatch object. What do I have 
to do to make my server recognize this as a PowerPoint.Application object so 
that I can access its attributes (and hopefully invoke its methods)?

Apologies for my lack of what is probably basic COM knowledge. Thanks, 
everyone.

-- Graham





More information about the Python-list mailing list