Hi monks,
I am opening excel application through Win32::OLE & drawing a chart. Then trying to export the chart to PNG file. This works fine when executed directly. But if I Execute it through shell object from ASP throughs an error saying
Win32::OLE(0.1403) error 0x800a03ec in METHOD/PROPERTYGET "Export" at C:\\timken_project\\export.pl li +ne 35
Earlier I had the same problem & had posted it in perlmonks. This problem was solved after installing Office XP with SP1. But now I need to make the same thing working on Office 2003. I tried installing SP1 for Office 2003, but it didn't work. Why is it working on Office XP but not on Office 2003. Though it is not a perl problem any suggestions will be of great help.
The perl code to export the graph is
use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use Win32::OLE; use Win32::OLE::Const; $Win32::OLE::Warn = 3; # die on errors... $file = "C:\\testw.txt"; open (TTT, ">$file") || die "error"; print TTT "test"; $filename = "C:\\book1.xls"; $filter = 'PNG'; # can be GIF, JPG, JPEG or PNG $pngnm = "C:\\test"; eval{ my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # use the Ex +cel application if it's open, otherwise open new my $Book = $Excel->Workbooks->Open( $filename ); # open the file foreach my $Sheet (in $Book->Sheets) { # loop through all sheets foreach my $ChartObj (in $Sheet->ChartObjects) { # loop through all chartobjects in the sheet #$datewk = join("".split(/\s+/, $Date)); $savename = "$pngnm" . ".$filter"; #$savename = "$dirpath\\$pngnm" . ".$filter"; # Write image to PNG file $ChartObj->Chart->Export({ FileName => $savename, FilterName => $filter, Interactive => 0 }); } } $Book->Close({SaveChanges=>0}); }; $err = $@; print TTT $err;
Thanks in advance

In reply to Excel 2003 + Perl by Nalina

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.