Win32 python and excel macros

John Coleman jcoleman at franciscan.edu
Wed Oct 18 14:21:14 EDT 2006


Mike P wrote:
> After just running trying that update it hits the macro perfectly but
> hten i get an error message after i type in a couple of values.. as per
> below
>
> Traceback (most recent call last):
>   File "<string>", line 148, in ?
>   File "<COMObject <unknown>>", line 14, in Run
>   File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
> 258, in _ApplyTypes_
>     result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType,
> argTypes) + args)
> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None,
> None, None, 0, -2146827284), None)
>
>
> I know you said you didn't know much about python, so if any other
> experts outthere can give me a clue.. i'll be very appreciative
>
> Mike

Mike,

Maybe you can use a little error handling in the VBA code to see if the
error is in the VBA or in the Python (or both)

At the top of  the sub that you call put the line

On Error GoTo err_handler

and at the bottom of the sub (right before the end sub) put:

err_handler:
  If Err.Number > 0 Then
    MsgBox "Error " & Err.Number & ": " & Err.Description
  End If

This will also give you some idea of what the error is from VBA's
perspective (although the error descriptions are not always very
informative).

HTH

-John Coleman




More information about the Python-list mailing list