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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.