Beginner COM problem (Windows)

Mark Hammond MarkH at
Mon Oct 22 12:37:41 CEST 2001

Kirby Urner wrote:

> I've written (actually downloaded [1]) a COM object in Visual FoxPro 5.
> I'd like Python to be its client.
> The object is registered, and when I write a macro in Excel, using VBA, 
> the behavior works as advertized.  


> However, when I try to do something similar in Python, with win32all 
> installed, the following occurs:
>   >>> import win32com.client
>   >>> vfpole = win32com.client.Dispatch("VFP_OLE.VFP_OLE_Server")
>   >>> vfpole
>   <COMObject VFP_OLE.VFP_OLE_Server>
>   >>> vfpole.FoxCommand ("Wait Window 'Executing Query' Nowait")
>   Traceback (most recent call last):
>     File "<pyshell#4>", line 1, in ?
>       vfpole.FoxCommand ("Wait Window 'Executing Query' Nowait")
>     File "D:\Program Files\Python21\win32com\client\", 
>     line 432, in   __getattr__
>       raise pythoncom.com_error, details
>   com_error: (-2147352567, 'Exception occurred.', (99, 'Visual FoxPro 
>   for Windows', 'Procedure canceled.', None, 0, 0), None)
> Any ideas?  I tried setting _unicode_to_string_ to 1, but that
> didn't make any difference.  
> I actually get an error the second I hit a parenthesis key 
> after vfpole.FoxCommand -- unless I move the (argument) out 
> a space -- legal.  That postpones the error message until after 
> I hit enter.  That behavior tells me something, but I'm not 
> sure what.

My guess is that FoxPro is allowing "FoxCommand" to be used as either a property or a method.  Try running makepy over the COM object and see if the behaviour corrects itself.


More information about the Python-list mailing list