473,803 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem using win32com

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("SDOE ngine.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.Workspac es.Add("ss")
File "C:\PYTHON23\li b\site-packages\win32c om\client\dynam ic.py", line 154, in __call__
return self._get_good_ object_(self._o leobj_.Invoke(* allArgs),self._ olerepr_.defaul tDispatchName,N one)
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.cl ient.gencache.E nsureModule("{A CE2C5EC-2EC0-4AEB-8B0D-27A5A1ED6421}", 0,10,0)
WS=SDO.Workspac es.Add("abc")

But now I get:

Traceback (most recent call last):
File "<interacti ve 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(Dis patchBaseClass) :
CLSID = IID('{7075CC61-F056-11D0-A34B-000000000000}')
coclass_clsid = IID('{7075CC63-F056-11D0-A34B-000000000000}')

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

class Workspaces(CoCl assBaseClass): # A CoClass
CLSID = IID('{7075CC63-F056-11D0-A34B-000000000000}')
coclass_sources = [
]
coclass_interfa ces = [
IWorkspaces,
]
default_interfa ce = 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
0 1822

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3880
by: Marc | last post by:
Hello, I've fiddled with this for quite a while and thought I had the problem solved. I had a version that would successfully compile and run. But then I had to change the code to use a different module, and now it will compile but not run again. I know that functionality in this area is not fully supported yet, but there has to be someone out there that has got this to work. I am using Python2.3, with py2exe 0.4.2, and win32all 159....
1
5199
by: Justin Stockton | last post by:
I recently upgraded from ActivePython 2.2.2 to ActivePython 2.3.2 and I'm running into an issue importing the win32com.client module. Before installing the new version, I made sure to properly remove old version (as well as the mx libraries I had installed). I then installed the new version as a user with the Administrator role. I know I'm technically not supposed to install to a directory with a space in the name, but it worked fine for...
1
1875
by: Cristian Hasbun from Chile | last post by:
I need a win32com guru please... i'm not python expert, but i understand mi trouble... Requirements: Hook EyesWeb 3.2.0 (http://www.eyesweb.org) COM Module with Python 2.0.1 i used win32com libraries and generate an early binding for module (using prog_id)
1
1800
by: Cristian Hasbun from Chile | last post by:
I need a win32com guru please... i'm not python expert, but i understand mi trouble... Requirements: Hook EyesWeb 3.2.0 (http://www.eyesweb.org) COM Module with Python 2.0.1 i used win32com libraries and generate an early binding for module (using prog_id)
1
3251
by: Martin Stettner | last post by:
Hi, when trying to generate the wrapper classes for Microsofts ADO Library (Version 2.8) with makepy, I run into the following problem. Here's what I do (I use ActiveState Python 2.4.1.245) 1.) Running makepy, selecting "Microsoft ActiveX Data Object 2.8" 2.) Starting PythonWin IDE
2
2076
by: Alexander Eisenhuth | last post by:
Hello together, My system: ActivePython 2.4.1 Windows XP I write a COM Server in VC++ 6.0 using ATL. So far so good. While I develop I got sometimes strange behaviour with makepy utility. Today again. :-(
8
4609
by: Joakim Persson | last post by:
Hello all. I am involved in a project where we have a desire to improve our software testing tools, and I'm in charge of looking for solutions regarding the logging of our software (originating from embedded devices). Currently, we are using a heavyweight, proprietary log tool developed by another part of the company. This tool contains all "standard" logging functionality, but we also need to insert "debug" log points in the software of...
1
3726
by: koia | last post by:
Hi, I have a problem with adding attributes to a Line in an Excel drawing using the Python win32com interface. From recording in Excel I get the Macro: Sub Makro1() ActiveSheet.Shapes.AddLine(192.75, 63.75, 316.5, 110.25).Select Selection.ShapeRange.Line.ForeColor.SchemeColor = 10 Selection.ShapeRange.Line.Visible = msoTrue
2
4688
by: Aleksandar Cikota | last post by:
Hi all, I have a problem with openning of an image. Here is the Code: from Tkinter import * from PIL import Image, ImageTk from win32com.client import gencache import tkMessageBox
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10542
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.