lvleph has asked for the wisdom of the Perl Monks concerning the following question:

I am having a problem. I need to add multiple series to one chart and so I don't believe I can use the ChartWizard.

Currently, I use the following code to add a series:
$Chart->SeriesCollection->Add($Sheet3->Range("D$num2:D$num1"));

This however does not set the XValues, which I try to do with the following code:
$Range = $Sheet3->Range("C$num2:C$num1");
$Chart->SeriesCollection($series)->XValues($Range); ;

This results in the following error:
Win32::OLE(0.1709) error 0x80020011: "Does not support a collection"
in METHOD/PROPERTYGET "XValues" at ./PollenAVG.pl line 149

Any Ideas? Thank you in advance.

Replies are listed 'Best First'.
Re: Win32::OLE Excel Chart Help
by Anonymous Monk on Jul 19, 2008 at 10:33 UTC
      I actually got that far using the macro-recorder in Excel. The following was the code given by the macro-recorder:
      ActiveChart.SeriesCollection(1).XValues = _ "='Differentiated Fathers'!$C$2:$C$26"

      I think I just don't know how to translate that.

      I originally tried
      $Chart->SeriesCollection($series)->{XValues} = $Range;
      But that gave the following error:
      Win32::OLE(0.1709) error 0x80020003: "Member not found"
      in PROPERTYPUTREF "XValues" at ./PollenAVG.pl line 150

      If I get rid of the curly braces:
      $Chart->SeriesCollection($series)->XValues = $Range;
      Can't modify non-lvalue subroutine call at ./PollenAVG.pl line 150.
Re: Win32::OLE Excel Chart Help
by lvleph (Initiate) on Jul 20, 2008 at 22:25 UTC
    Okay, after days of searching and finding many many people with the exact same problem and no solution ever given, I have found the solution. Translating this VBA would not work, the code is completely different.

    Solution:
    $Chart->SeriesCollection(1)->LetProperty('XValues', $Range);

    I found this solution in a post by ralife. Thank you for figuring this out for me with out even knowing.:)
Re: Win32::OLE Excel Chart Help
by Anonymous Monk on Jul 20, 2008 at 05:36 UTC
    No other suggestions? I have been searching and searching. I can't even seem to find Win32:OLE documentation to try figuring this out myself.