Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > win32::OLE and SeriesCollection on a chart

Reply
Thread Tools

win32::OLE and SeriesCollection on a chart

 
 
axroh
Guest
Posts: n/a
 
      07-05-2007
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.

 
Reply With Quote
 
 
 
 
axroh
Guest
Posts: n/a
 
      07-10-2007
Hello again,

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

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 <(E-Mail Removed)> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A real challenge: Create a Gantt-chart-like chart gnewsgroup ASP .Net 4 02-06-2008 02:27 PM
ASP can generate a chart (pie chart) ? Tarek ASP General 6 11-19-2004 06:33 PM
Excel Chart SeriesCollection Error Brian Shade Perl 0 09-09-2004 02:37 PM
Win32::OLE Excel Chart SeriesCollection. Problem changing from Excel 2000 to 2002 moller@notvalid.se Perl Misc 1 07-05-2004 10:50 AM
Line Chart in ASP.NET and C# Bruce Schechter ASP .Net 5 11-22-2003 05:41 AM



Advertisments