pawansharma01 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I have a perl application which was working fine in MS Excel 2003. We got upgraded to Office 2007 and the application stopped working. On troubleshooting I have narrowed it down to "ApplyDataLabel" when its trying to create a chart. the code lines are .... my $book = $excel->workbooks->add; my $sheet = $book->worksheets(1); . . . my $Chart = $excel->Charts->Add; $chart->{ChartType} = xlColumnClustered; $Chart->{DepthPercent} = 100 || win32_error("DepthPercent"); $Chart->{HasLegend} =0 || win32_error("HasLegend"); $Chart->SetSourceData({Source=>$Range, PlotBy =>xlColumns}); $Chart->SeriesCollection(1)->ApplyDataLabels->{AutoText}=1; $Chart->SeriesCollection(1)->ApplyDataLabels->{ShowValue}=1; The code works fine in Excel 2003 but dies in 2007 at the line: $Chart->SeriesCollection(1)->ApplyDataLabels->{AutoText}=1; complaining that cannot set hash reference with null values ??? On Commenting this the code processes through and finishes running. The charts are drawn , just that they are missing some borders. It appears that something changes in Excel 2007 from 2003 which has broken the method "ApplyDataLabels". IS anybody aware of any such changes ?? Thank You, regards,
  • Comment on Perl Win32::OLE Excel Charts -- ApplyDataLabels

Replies are listed 'Best First'.
Re: Perl Win32::OLE Excel Charts -- ApplyDataLabels
by jrsimmon (Hermit) on Jul 16, 2009 at 18:11 UTC

    The easiest way to track down changes between versions is to perform the steps in Excel while recording a macro. You can then view the macro to see how Excel 2007 differs from Excel 2003.

    Also, please encapsulate any code in <code></code> tags. See How do I compose an effective node title? and How do I post a question effectively? for additional ways to improve the readability of your posts.

      Thanks. I will follow the post instructions & and step through the Macros for different versions.