Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32::OLE Excel Chartwizard sizes

Status
Not open for further replies.

mlibeson

Programmer
Mar 6, 2002
311
US
Hello gurus,

I am trying to manipulate a chart I created using the Win32::OLE chartwizard code as follows:

Code:
$chart1->Chart->ChartWizard($ws->Range("A40", "B42", xlPie, 7, xlColumns, 1, 0, 0, '', '', '', '');

What code do I use to change the font size of the category labels on the pie graph? I'v tried figuring it out looking at the VB library in excel, but have not been able to get it correct. To access the VB library, open excel, then view the visual basic editor and press the "F2" key.

How do I make the pie bigger without resizing anything else?


Michael Libeson
 
I created a macro in excel of what I want to accomplish for setting the font size to 6 for the category labels, but what does it look like ine PERL code. See Macro code below:

Code:
Sub Macro1()
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.SeriesCollection(1).DataLabels.Select
    Selection.AutoScaleFont = True
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "Regular"
        .Size = 6
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .Background = xlAutomatic
    End With
End Sub


Michael Libeson
 
The following code seems to work:

Code:
$chart1->Chart->SeriesCollection(1)->DataLabels->Font->{Size} = 6;


Michael Libeson
 
hmmm... do you always talk to yourself like this? [wink]



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Here a cnversion using Vb Script Converter (PDK activeState tool). I have found ot very useful.

Cheers

Code:
#!perl

use Win32::OLE qw( with);
use constant xlAutomatic => -4105;
use constant xlUnderlineStyleNone => -4142;

my $_app_object = (Win32::OLE->GetActiveObject('Excel.Application') ||
                   Win32::OLE->new('Excel.Application'));

sub Macro1 {
    $_app_object->ActiveSheet->ChartObjects('Chart 2')->Activate();
    $_app_object->ActiveChart->SeriesCollection(1)->DataLabels->Select();
    $_app_object->Selection->{AutoScaleFont} = 1;
    {
        my $_with001 = $_app_object->Selection->Font;
        with ($_with001,
              Name => 'Arial',
              FontStyle => 'Regular',
              Size => 6,
              Strikethrough => 0,
              Superscript => 0,
              Subscript => 0,
              OutlineFont => 0,
              Shadow => 0,
              Underline => xlUnderlineStyleNone,
              ColorIndex => xlAutomatic,
              Background => xlAutomatic,
        );
    }
}




dmazzini
GSM/UMTS System and Telecomm Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top