Win32::OLE Excel problem

A

ancient

I am trying to create a Chart using win32::OLE and excel. I have
everything working except generating the background for the Chart.
The command I am using is --

$Excel->ActiveChart->ChartArea->Fill->{Visible} =1;
$Excel->ActiveChart->ChartArea->Fill->{ForeColor}->{SchemeColor} = 17;
$Excel->ActiveChart->ChartArea->Fill->{BackColor}->{SchemeColor} = 2;
$Excel->ActiveChart->ChartArea->Fill->TwoColorGradient({
Style => "msoGradientHorizontal",
Variant => 1 });

Everything seems to work until it hits TwoColorGradient. It finishes
executing, but does not set two colors for the gradient. It just
shows the ForeColor.

I would appreciate any help. I am soooo close!
 
J

Jay Tilton

(e-mail address removed) (ancient) wrote:

: I am trying to create a Chart using win32::OLE and excel. I have
: everything working except generating the background for the Chart.
: The command I am using is --
:
: $Excel->ActiveChart->ChartArea->Fill->{Visible} =1;
: $Excel->ActiveChart->ChartArea->Fill->{ForeColor}->{SchemeColor} = 17;
: $Excel->ActiveChart->ChartArea->Fill->{BackColor}->{SchemeColor} = 2;
: $Excel->ActiveChart->ChartArea->Fill->TwoColorGradient({
: Style => "msoGradientHorizontal",
: Variant => 1 });
:
: Everything seems to work until it hits TwoColorGradient. It finishes
: executing, but does not set two colors for the gradient. It just
: shows the ForeColor.

msoGradientHorizontal is the name of a constant in MSOffice. You're
passing it to the method as a string. Not the same thing.

Import the Office constants into your program's namespace so you can use
the msoGradientHorizontal constant:

use Win32::OLE::Const 'Microsoft Office';

# stuff elided

$Excel->ActiveChart->ChartArea->Fill->TwoColorGradient({
Style => msoGradientHorizontal,
Variant => 1 });

You might also declutter things with a for() loop to alias a repeatedly
used object:

for( $Excel ->ActiveChart ->ChartArea ->Fill ) {
$_ ->{Visible} =1;
$_ ->{ForeColor} ->{SchemeColor} = 17;
$_ ->{BackColor} ->{SchemeColor} = 2;
$_ ->TwoColorGradient({
Style => msoGradientHorizontal,
Variant => 1
});
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top