[python-win32] Unable to use win32com on Ecco COM server despite success with VB and Perl COM

Raymond Yee yee@uclink.berkeley.edu
Mon, 22 Apr 2002 10:21:43 -0700


[I've previously posted to comp.lang.python but am still stuck:
http://groups.google.com/groups?dq=ccomp.lang.python&hl=en&group=comp.lang.python&safe=off&selm=e5eab55e.0204191549.41985d9a%40posting.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?)

(I'm running ActivePython version 2.2.0 build 221 change 37890 on
Windows 2000 Professional)


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

--
Raymond Yee                          44 Barrows Hall, #3810
Technology Architect                            UC Berkeley
Interactive University Project      Berkeley, CA 94720-3810
yee@uclink.berkeley.edu                 510-642-0476 (work)
http://www.raymondyee.net               413-541-5683  (fax)