win32com Excel bug?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cfriedalek@gmail.com

    #1

    win32com Excel bug?

    I'm driving Excel from python, largely successfully. Now I'm trying to
    add errorbars to XY scatter plots. Keep getting a com_error. Can't
    track down the problem.

    I modified a simple example to duplicate the problem. Thanks to Mathieu
    Fenniak http://www.stompstompstomp.com/weblog/entries/67/ for the code.

    The traceback is shown below. You can see that the Excel chart series
    has a method called ErrorBar. But when I try to use it with any or all
    of its allowed arguments, it fails. The traceback goes into the guts of
    win32com but I don't really have a clue at that point. (Happy to learn
    something new though).

    The relevant Excel VBA language doc is here.
    http://msdn.microsoft.com/library/de...HV03076818.asp

    Hope someone can help. Losing hair .... fast!



    In [16]: %run test.py
    --Return--[color=blue]
    > c:\python23\lib \pdb.py(992)set _trace()->None[/color]
    -> Pdb().set_trace ()
    (Pdb) c
    There's a method waiting
    ---------------------------------------------------------------------------
    pywintypes.com_ error Traceback (most
    recent call
    last)

    c:\temp\mpival\ test.py
    79
    80 # A simple example:
    ---> 81 plot( (1,2,3,4,5), (6,7,8,9,10) )
    82
    83 # Some more data:

    c:\temp\mpival\ test.py in plot(x, y, xAxisLog, yAxisLog)
    35 if series.ErrorBar :
    36 print "There's a method waiting"
    ---> 37 series.ErrorBar (Direction = constants.xlY)
    38
    39

    C:\Python23\lib \site-packages\win32c om\gen_py\00020 813-0000-0000-C000-0000000000
    46x0x1x4.py in ErrorBar(self, Direction, Include, Type, Amount,
    MinusValues)
    22722 , MinusValues=def aultNamedOptArg ):
    22723 return self._ApplyType s_(152, 1, (12, 0), ((3,
    1), (3, 1
    ), (3, 1), (12, 17), (12, 17)), 'ErrorBar', None,Direction[color=blue]
    > 22724 , Include, Type, Amount, MinusValues)[/color]
    22725
    22726 def Paste(self):

    C:\Python23\lib \site-packages\win32c om\client\__ini t__.py in
    _ApplyTypes_(se lf,
    dispid, wFlags, retType, argTypes, user, resultCLSID, *args)
    444 def _ApplyTypes_(se lf, dispid, wFlags, retType,
    argTypes, user,
    445 resultCLSID, *args):
    --> 446 return self._get_good_ object_(
    447 self._oleobj_.I nvokeTypes(
    448 dispid, 0, wFlags, retType,
    argTypes, *arg
    s),

    com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel',
    'ErrorBar
    method of Series class failed', 'C:\\Program Files (x86)\\Microsof t
    Office\\Off
    ice10\\1033\\xl main10.chm', 0, -2146827284), None)
    WARNING: Failure executing file: <test.py>

  • Roger Upole

    #2
    Re: win32com Excel bug?

    <cfriedalek@gma il.com> wrote in message news:1145426529 .989164.212450@ g10g2000cwb.goo glegroups.com.. .[color=blue]
    > I'm driving Excel from python, largely successfully. Now I'm trying to
    > add errorbars to XY scatter plots. Keep getting a com_error. Can't
    > track down the problem.
    >
    > I modified a simple example to duplicate the problem. Thanks to Mathieu
    > Fenniak http://www.stompstompstomp.com/weblog/entries/67/ for the code.
    >
    > The traceback is shown below. You can see that the Excel chart series
    > has a method called ErrorBar. But when I try to use it with any or all
    > of its allowed arguments, it fails. The traceback goes into the guts of
    > win32com but I don't really have a clue at that point. (Happy to learn
    > something new though).
    >
    > The relevant Excel VBA language doc is here.
    > http://msdn.microsoft.com/library/de...HV03076818.asp
    >
    > Hope someone can help. Losing hair .... fast!
    >
    >
    >
    > In [16]: %run test.py
    > --Return--[color=green]
    >> c:\python23\lib \pdb.py(992)set _trace()->None[/color]
    > -> Pdb().set_trace ()
    > (Pdb) c
    > There's a method waiting
    > ---------------------------------------------------------------------------
    > pywintypes.com_ error Traceback (most
    > recent call
    > last)
    >
    > c:\temp\mpival\ test.py
    > 79
    > 80 # A simple example:
    > ---> 81 plot( (1,2,3,4,5), (6,7,8,9,10) )
    > 82
    > 83 # Some more data:
    >
    > c:\temp\mpival\ test.py in plot(x, y, xAxisLog, yAxisLog)
    > 35 if series.ErrorBar :
    > 36 print "There's a method waiting"
    > ---> 37 series.ErrorBar (Direction = constants.xlY)[/color]


    According to the docs, the Include and Type arguments are
    required, and they're not being passed to the method.

    hth
    Roger



    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

    Comment

    • cfriedalek@gmail.com

      #3
      Re: win32com Excel bug?

      yth (Yes That Helped).

      You know how it goes, I thought I'd already tried to include all
      arguments. Obviously I didn't, or stuffed it up in some other way.
      Also some confusion about the meaning of "required" and "default". The
      doc explains these arguments as required, but some have defaults. I
      guess I thought if they had defaults then they didn't need to be
      specified.

      Anyway, problem solved. Thanks again.

      Comment

      Working...