Using the help for VBA:
...
Use the Add method to create a new, empty embedded chart and add it to the
collection. Use the ChartWizard method to add data and format the new chart.
The following example creates a new embedded chart and then adds the data
from cells A1:A20 as a line chart.

Dim ch As ChartObject
Set ch = Worksheets("sheet1").ChartObjects.Add(100, 30, 400, 250)
ch.Chart.ChartWizard source:=Worksheets("sheet1").Range("a1:a20"), _
    gallery:=xlLine, title:="New Chart"
....
I think  the Add method below:
my $ExtensionsBlockedChart = $Book->Charts->Add;

takes the default values for Before,After, and Count.
Question How do I place the chart near the sheet
that I wish to insert the chart into?
I tried:
my $ExtensionsBlockedChart = $Book->Charts->Add(4,5,1);
and I got
OLE exception from "Microsoft Excel":

Unable to get the Add property of the Sheets class

Win32::OLE(0.1502) error 0x800a03ec
    in METHOD/PROPERTYGET "Add" at xxx.pl line 286


-----Original Message-----
From: Jacob, Raymond A [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 21, 2001 12:37 AM
To: [EMAIL PROTECTED]
Subject: OLE - excel chart placement in multi-sheet Excel file


Looking at TPJ#10 and B_Paul_B post[included] about OLE - excel chart
placement.
Like B_Paul_B when I used $Sheet->Location(xlLocationAsObject, 'my sheet');.
The
chart was put on the first page. So I tried B_Paul_B's method. I got a chart
area but not chart. I noticed that the range and the other default values
that came with xlLocation were not copied over. A previous response to 
B_Paul_B mentioned that the constants were not intialized correctly. I
set the first parameter in the Location method to 2. Still no luck.
Any suggestions would be helpful.

Snippet of My code:
...
use Win32::OLE qw(in valof with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::NLS qw(:DEFAULT :LANG :SUBLANG);
..
$ExtensionsBlockedSheet->Activate;
$ExtensionsBlockedSheet->Range("B:C")->Select;
# insert chart as object on correct sheet but no data
my @ChartPos = (120,120,360,360);
my $ExtensionsBlockedChart =
$ExtensionsBlockedSheet->ChartObjects->Add(@ChartPos)->Chart;
....
# insert chart as object on 1st page only.
# my $ExtensionsBlockedChart = $Book->Charts->Add;
# $ExtensionsBlockedChart->Location(xlLocationAsObject,
$ExtensionsBlockedSheet->{Name});
$ExtensionsBlockedChart->{ChartType} = xlColumnClustered;

=================================================
Re: OLE - excel chart placement    add this thread to my home page  
by B_Paul_B other posts by this author 
Oct 2 2001 4:37AM messages near this date 
----------------------------------------------------------------------------
----
  Re: OLE - excel chart placement       |      Re: OLE - excel chart
placement    

Folks...
I never like to leave a problem unsolved.  So, whether anyone cares or 
not, here is the solution to my posted problem.  Maybe some poor 
b@stered down the road will benefit.

Fist off, forget using the Location method in Perl to move your charts 
(if at all possible, at least until it is fixed).  There is something 
VERY wrong with this method (as implemented in Perl).  Put your charts 
on the correct sheet to begin with (if you can) using this methodology:

my @Pos = (120*($Row-2), 120*($Col+0.5), 120, 120);
my $Chart = $Sheet->ChartObjects->Add(@Pos)->Chart;

I had almost figured this one out on my own, but it was that little 
"->Chart" on the end that got me.  Apparently, its not needed in the VB 
version.  At least, it wasn't used in the example I saw.  Anyways, my 
charts are all happy now, and by no coincidence, so am I.

Many thanks to Jan Dubois for her serendipitous help solving this 
problem with her post to this very same mailing list on Jul 18 2001.

Now.  That's satsfaction.

Cheerios,
Paul

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to