[python-win32] python COM-Server and VBScript

Tim Roberts timr at probo.com
Fri Jun 23 19:27:40 CEST 2006


On Fri, 23 Jun 2006 07:12:03 +0200, Frank G?nther <f.g.- at gmx.de> wrote:

> 
>
>I found a strange behaviour when I use a python-COM-Server together with VB.
>  
>

Not VB, but rather VBS.  They are two rather different languages.

>It seems that the first argument of a COM-Method that is passed by a
>VB-variable is set to VB-Nothing after the Method call.
>  
>

Actually, it is set to whatever is returned from the method.  You happen
to return None, which VBS translates to a Nothing.  If you change it to
return something, like a string, that's what you'll see in your VBS script.

>For example if I use the code below: After calling 
>
>testSrvObj.SetValue what, value
>
>what is deleted, but not value. But after calling
>
>            testSrvObj.SetValue "ABC", value
>
>value is deleted.
>
>Has anybody an idea what is the problem?
>  
>

This is just a VBS weirdness when calling COM methods.  Calling your COM
server from Python works perfectly, and turning on the debug tracing
shows nothing unusual.  It gets two input parameters that are not modified.

VBS does have some strange rules about COM method calls and return
values.  You can eliminate this problem by having your VBS code fetch
the return value:

  WScript.Echo testSrvObj.SetValue( what, value )
  WScript.Echo testSrvObj.SetValue( "ABC', value )
--or--
  retvalue = testSrvObj.SetValue( what, value )
  retvalue = testSrvObj.SetValue( "ABC', value )

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list