By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,767 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,767 IT Pros & Developers. It's quick & easy.

Problem using win32com

P: n/a
Hi,

A month ago, I decided to move from Delphi to Python/wxPython for a good deal of my development work, and for the past few projects (which included a full re-write of our point-of-sale system) I've had no problems and been very pleased with the move.

We're Sage (accounting software) developers and frequently link into Line 50 using a Sage supplied COM server. In Delphi, the code to create the client and a workspace (which is required later) is as follows:

SDO := CreateOLEObject('SDOEngine.10');
WS := SDO.Workspaces.Add('abc');

So naturally, I'd expect the following Python code to work:

import win32com.client
SDO = win32com.client.Dispatch("SDOEngine.10")
WS = SDO.Workspaces.Add("abc")

But at the last stage, I get an error:

Traceback (most recent call last):
File "<pyshell#4>", line 1, in -toplevel-
ws=sdo.Workspaces.Add("ss")
File "C:\PYTHON23\lib\site-packages\win32com\client\dynamic.py", line 154, in __call__
return self._get_good_object_(self._oleobj_.Invoke(*allAr gs),self._olerepr_.defaultDispatchName,None)
com_error: (-2147352573, 'Member not found.', None, None)

So I used MakePy to generate the relevant Python interface code, and tried the following:

SDO=win32com.client.gencache.EnsureModule("{ACE2C5 EC-2EC0-4AEB-8B0D-27A5A1ED6421}",0,10,0)
WS=SDO.Workspaces.Add("abc")

But now I get:

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: unbound method Add() must be called with IWorkspaces instance as first argument (got str instance instead)

The relevant MakePy generated code looks like this:

class IWorkspaces(DispatchBaseClass):
CLSID = IID('{7075CC61-F056-11D0-A34B-000000000000}')
coclass_clsid = IID('{7075CC63-F056-11D0-A34B-000000000000}')

def Add(self, Name=defaultNamedNotOptArg):
ret = self._oleobj_.InvokeTypes(2, LCID, 1, (9, 0), ((8, 0),),Name)
if ret is not None:
ret = Dispatch(ret, 'Add', None, UnicodeToString=0)
return ret

class Workspaces(CoClassBaseClass): # A CoClass
CLSID = IID('{7075CC63-F056-11D0-A34B-000000000000}')
coclass_sources = [
]
coclass_interfaces = [
IWorkspaces,
]
default_interface = IWorkspaces

What am I doing wrong? And more importantly, what can I do about it? I suspect there's a really simple answer which begins "Chris, you're being a fool...", but it's now pretty late, and I have other matters to deal with for the next few hours, so any help would be much appreciated.

Regards,
Chris

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.