• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1509
  • Last Modified:

Perl Win32::OLE Microsoft Excel Set font size in chart legend and datatable

I'm not a Perl programmer and have inherited a Perl script that uses OLE animation to create data and charts in an Excel spreadsheet.

The charts have a terrible appearance primarily due to text font sizes -- at the normal 10-point size they take up enough room that the actual graph gets compressed and becomes useless.  I've made the charts look good in Excel by reducing the text point sizes -- I've set them to 3-point at the moment.

I've been able to update the Perl script to set font sizes for the chart title and the X and Y axis titles.

My problem is that I can't seem to do the same for the datatable and legend fonts.  The attached source contains
   #Not a CODE reference
just before each of the two commented out lines representing my attempts to the set font sizes.  "Not a CODE reference" is the problem I'm seeing for each.
  • 2
1 Solution
josgoodAuthor Commented:
Added Excel forum.
The error you're getting is caused by the parens.  They should be curly brackets:

  $chart->(DataTable)->{Font}->{Size} = 3;

Should be:

  $chart->{DataTable}->{Font}->{Size} = 3;


  $chart->(Legend)->{Font}->{Size} = 3;

Should be:

  $chart->{Legend}->{Font}->{Size} = 3;

Don't have excel to test that Legend and Datatable are objects of a chart (and if they are whether they have a font object with a size property), but assuming that the following would work in vba:

  chart.Legend.Font.Size = 3


  chart.Datatable.Font.Size = 3

then the above bracketed version should work in perl.
josgoodAuthor Commented:
Thank you!

That is exactly the answer I needed.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now