in reply to Problem Graphing to Excel with Win32::OLE

I am not sure, but I think

$mcr_crtime_chart->Legend->{Position} = xlRight;

should be

$mcr_crtime_chart->Legend->{Position} = xlLegendPositionRight;

You may want to search msdn, check out XlLegendPosition Enumeration:
Specifies the position of the legend on a chart. Name Value Description xlLegendPositionBottom -4107 Below the chart. xlLegendPositionCorner 2 In the upper right-hand corner of the c +hart border. xlLegendPositionCustom -4161 A custom position. xlLegendPositionLeft -4131 Left of the chart. xlLegendPositionRight -4152 Right of the chart.

I can't test this right now, as I do not have access to a Windows system (I am not at work). Give it a shot and let us know how you get on.

Hope this helps

Martin

Replies are listed 'Best First'.
Re^2: Problem Graphing to Excel with Win32::OLE
by Phoenix Rising (Initiate) on Jun 05, 2008 at 19:59 UTC
    Similarly, I believe HasTitle and HasLegend need to be set to one of the various "True" options, perhaps msoTrue or the variant True. (MSDN documentation does not describe HasTitle.)
      Ah, nice catch, perhaps

      $mcr_crtime_chart->ChartTitle->{Text} = "MCRByURN-CreateTime";

      Should be:

      $mcr_crtime_chart->ChartTitle->{Characters}->{Text} = "MCRByURN-CreateTime";

      Sometimes if find it difficult to find things via the msdn search, and I have never been a huge fan of the Microsoft documentation.

      It may also be worth checking out the URLs I link to in this node.

      Martin
      If you notice the code I place the
      $mcr_crtime_chart->{HasLegend} = 1;
      and the as well
      $mcr_crtime_chart->{HasTitle} = 1;

      but neither seem to work when I uncomment those lines of code and if I try to name the chart $mcr_crtime_chart->ChartTitle->{Text} = "CreateTime"; it fails.

      I tried the XlLegendPosition Enumeration and it doesn't seem to work either.
        are the errors produced by these changes any different to the ones in your first post in this thread?

        I would suggest getting a basic script up and running that simply generates a chart, then add the features you want, as I said you should double check the Microsoft Documentation, to makes sure you are calling things properly.

        Another alternative, and I don't like to mention it, but.., it may be feasable to create an excel macro to do what you want, then simply call it from perl. See Re: Running an excel macro from Perl for further details.

        If I had access to a Windows machine, I would try as I suggested, take it back to basics, create a stand alone script to simply open Excel then create a basic chart, then start adding chart features/properties until I had what you are looking for, then integrate the working example into your main script.

        Martin