Beginner COM problem (Windows)
Kirby Urner
urner at alumni.princeton.edu
Sun Oct 21 02:23:59 EDT 2001
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.
Here's the VBA from Excel:
Sub test()
'-- Declare variable to hold the reference
Dim VFPOLE As Object
'-- Assign object reference to variable
Set VFPOLE = CreateObject("VFP_OLE.VFP_OLE_Server")
VFPOLE.FoxCommand _
("Wait Window 'Executing Query' Nowait")
VFPOLE.FoxCommand ("Select * From G:\VFPAPPS\PATS\ACC\CVL1 " & _
"Into Table TestAll3")
VFPOLE.FoxCommand ("CLOSE ALL")
VFPOLE.FoxCommand ("Wait Clear")
'-- Release the reference
Set VFPOLE = Nothing
End Sub
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\dynamic.py",
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.
Pls CC: urnerk at qwest.net and/or urner at alumni.princeton.edu
Muchas gracias,
Kirby
More information about the Python-list
mailing list