Unable to use win32com on Ecco COM server despite success with VB and Perl COM

dsavitsk dsavitsk at e-coli.net
Sat Apr 20 14:12:09 EDT 2002


I don't know the answer to this, but (a) noone else seems to be answering,
and (b) i can give a little bit of information that might be helpful.

If one creates a method in a VB class like

Public Function X (a as String, b as String)
    X = 1
End Function

Then calls it from Python like
>>> y = com_object.X('a', 'b')
>>> print y
(1, u'a', u'b')

whereas if a and b are specified ByVal

Public Function X (ByVal a as String, ByVal b as String)
    X = 1
End Function

then
>>> y = com_object.X('a', 'b')
>>> print y
1

So, you might be able to just use
>>> y[0] to get the return value.

This doesn't seem to address your problem exactly, but maybe it will shed
some light on what is going on.

-doug


"Raymond Yee" <yee at uclink.berkeley.edu> wrote in message
news:e5eab55e.0204191549.41985d9a at posting.google.com...
> I've been trying unsuccesfully to use Python to access the
> functionality of the "Visual Basic Toolkit"
> (http://www.ivitar.com/vbecco/). The toolkit is a COM InProc
> Server (.exe).
>
> I'm puzzled as to how to proceed because of two things:  1) My
> Python program is able to use some functions of the toolkit but
> not others and 2) I've had success with both Visual Basic and Perl
> in accessing the toolkit via COM.
>
> Below are the three versions of the program.  Ecco is a personal
> information manager.  This program is supposed to print out the
> text of any selected outline and the corresponding URL in a folder
> called "Net Location"  (The developer key has beeen x'ed out)
>
> In the Perl and VB versions, I am able to get both the "text
> value" of the selected item ($item->Text in Perl) and the
> corresponding URL ($item->FolderValue("Net Location")).  However,
> in the Python version, while EccoItem.Text is what I expect,
> EccoItem.FolderValue("Net Location") returns
>
> (u'Net Location', None)
>
> -- a tuple, whose first item is type unicode.  However, I don't
> see anything in the return value remotely related to the URL I'm
> trying to access.
>
> Any suggestions on how to get Python to work with the toolkit? (Am
> I using the wrong syntax?  Are there options I'm setting right?
> How should I debug this?)
>
> Thanks in advance,
>
> -Raymond Yee
>
> ---------------------------------------------------------------
> Python version:
>
> # build OPML from the selected outline (if more than one is selected,
> use the first item
>
> import win32com.client
> Ecco = win32com.client.Dispatch("VBEcco.EccoApp")
> Ecco.Register("xxxxxxxx", -1, -1)
> EccoSelection = Ecco.Selection
>
> #print value of item in Net Location folder
>
> for EccoItem in EccoSelection:
>     print "Text: " + EccoItem.Text
>     print EccoItem.FolderValue("Net Location")
>
> ---------------------------------------------------------------
>
> Perl version:
>
> # establish COM connection to Ecco
>
> use Win32::OLE qw(in);
> #use Win32::OLE::in;
>
> my($ecco, $sel, $item);
>
> $ecco = Win32::OLE->new("VBEcco.EccoApp", 'Quit');
> $ecco->Register("xxxxxxxx", -1, -1);
>
> $sel = $ecco->Selection;
>
> foreach $item (in($sel)) {
>
>     print $item->Text, "\n";
>     print $item->FolderValue("Net Location") , "\n";
>
> }
>
> ---------------------------------------------------------------
>
> Visual Basic version:
>
> Option Explicit
>
> 'Place in Declarations
> Dim Ecco As EccoApp
> Dim EccoSelection As EccoItems
> Dim EccoItem As EccoItem
>
> Private Sub Form_Load()
>
> Set Ecco = New EccoApp
> Ecco.Register "xxxxxxxx", -1, -1
>
> ' Get Selections
> Set EccoSelection = Ecco.Selection
>
> 'if there is a first selection, print out the text, and figure out
> whether there is an associated URL in the Net Location folder
>
> For Each EccoItem In EccoSelection
>     MsgBox ("Text: " + EccoItem.Text)
>     MsgBox ("NL: " + EccoItem.FolderValue("Net Location"))
> Next
>
>
> End Sub





More information about the Python-list mailing list