win32::OLE and SeriesCollection on a chart

Discussion in 'Perl Misc' started by axroh, Jul 6, 2007.

  1. axroh

    axroh Guest

    Hi folks,

    I'm trying to do something like this:

    $Sheet->Range("A1:C1")->Select;
    my $y = $Excel->Selection;
    my $x = $Sheet->Range($y, $y->End(xlDown));
    my $Chart = $Book->Charts->Add;
    $Chart->{ChartType} = xlXYScatterSmooth;
    $Chart->SetSourceData($x,xlColumns);
    $Chart->Location(xlLocationAsObject,$Sheet->Name);
    $Chart->SeriesCollection(1)->Select;
    $Chart->SeriesCollection(1)->{AxisGroup} = xlPrimary;

    Everything is working fine until I access the SeriesCollection
    property. I keep getting:
    Can't call method "Select" on an undefined value at <filename> line
    <line_number>

    Even if I disable that line (I really don't need to select it, this
    was inherited from a VBA macro -- hence the selection), I get the same
    error for the next line. It's almost as if SeriesCollection is not an
    object for Chart.

    My range of data (A:A)->(C:C) are just numbers I wish to plot.

    Any help here would be greatly appreciated.
    axroh, Jul 6, 2007
    #1
    1. Advertising

  2. axroh

    axroh Guest

    Hello again,

    It took me days to figure this out, I was really hoping to have saved
    some time by asking on this group :p

    Basically, if you change the location of a chart:

    $Chart->Location(xlLocationAsObject,$Sheet->Name);

    You need to update the handle, since it is lost. Luckily, there is
    'ActiveChart':

    # STUPID EXCEL BUG - CAUSED ME HOURS OF FRUSTRATION
    # Chart handle is lost when you move the location of
    # the chart. Stupid.
    $Chart = $Excel->ActiveChart;

    And then all else works ok. Hope this helps someone.



    On Jul 5, 4:46 pm, axroh <> wrote:
    > Hi folks,
    >
    > I'm trying to do something like this:
    >
    > $Sheet->Range("A1:C1")->Select;
    > my $y = $Excel->Selection;
    > my $x = $Sheet->Range($y, $y->End(xlDown));
    > my $Chart = $Book->Charts->Add;
    > $Chart->{ChartType} = xlXYScatterSmooth;
    > $Chart->SetSourceData($x,xlColumns);
    > $Chart->Location(xlLocationAsObject,$Sheet->Name);
    > $Chart->SeriesCollection(1)->Select;
    > $Chart->SeriesCollection(1)->{AxisGroup} = xlPrimary;
    >
    > Everything is working fine until I access the SeriesCollection
    > property. I keep getting:
    > Can't call method "Select" on an undefined value at <filename> line
    > <line_number>
    >
    > Even if I disable that line (I really don't need to select it, this
    > was inherited from a VBA macro -- hence the selection), I get the same
    > error for the next line. It's almost as if SeriesCollection is not an
    > object for Chart.
    >
    > My range of data (A:A)->(C:C) are just numbers I wish to plot.
    >
    > Any help here would be greatly appreciated.
    axroh, Jul 10, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Shade

    Excel Chart SeriesCollection Error

    Brian Shade, Sep 9, 2004, in forum: Perl
    Replies:
    0
    Views:
    989
    Brian Shade
    Sep 9, 2004
  2. Patrick.O.Ige

    Ole ole

    Patrick.O.Ige, Jul 16, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    476
    Patrick.O.Ige
    Jul 16, 2006
  3. Drew Pihera
    Replies:
    0
    Views:
    620
    Drew Pihera
    Feb 4, 2004
  4. Lance Hoffmeyer
    Replies:
    0
    Views:
    228
    Lance Hoffmeyer
    Nov 17, 2003
  5. Replies:
    1
    Views:
    803
Loading...

Share This Page