Win32::OLE Excel problem

Discussion in 'Perl Misc' started by ancient, Nov 19, 2004.

  1. ancient

    ancient Guest

    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!
     
    ancient, Nov 19, 2004
    #1
    1. Advertising

  2. ancient

    Jay Tilton Guest

    (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
    });
     
    Jay Tilton, Nov 19, 2004
    #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. M. David Allen

    Win32::OLE, Excel, and coloring

    M. David Allen, Jun 24, 2003, in forum: Perl
    Replies:
    1
    Views:
    5,415
    Jay Tilton
    Jun 25, 2003
  2. M. David Allen

    Win32::OLE, Excel, and coloring

    M. David Allen, Jun 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    195
    Jay Tilton
    Jun 25, 2003
  3. Richard S Beckett

    Win32-OLE, excel, and empties.

    Richard S Beckett, Jul 11, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    254
    Jay Tilton
    Jul 11, 2003
  4. Lance Hoffmeyer
    Replies:
    0
    Views:
    254
    Lance Hoffmeyer
    Nov 17, 2003
  5. Replies:
    1
    Views:
    858
Loading...

Share This Page