String conversion between VBA and Python COM server

Nikolai Kirsebom nikolai.kirsebom at siemens.no
Mon Sep 27 10:26:54 EDT 1999


I've made a (test) COM server which is to act as a regular expression
'machine' for a VBA system.  I've got the server running and access to
the server works.  However, I have some problems in passing/retreiving
the string content.

In Word97/VBA:

Set RegMach = CreateObject("servername")
v = RegMatch.GetCurrent(ActiveDocument.Content)
MsgBox v



In Python server

class ....
   def GetCurrent(self, DocContent):
      return str(DocContent)


The message box in VBA will show the line:
<PyIDispatch at 0x272bbb4 with obj at 0x1302154>


If I replace the *return str(DocContent)* line  with only *return
DocContent* in the GetCurrent method, the text returned to the client
is ok - however if I do that, the content is in read-only mode.  This
means I'm not able to analyze the content.

Any hints is appreciated.

(Runneing Python 1.5.2b, Pythonwin build 125)

Thanks 

Nikolai






More information about the Python-list mailing list