in reply to Win32::OLE(0.1702) error 0x80020011
At any rate, your code bombs out because you are trying to use the Windows handle when you really do not need to. Here is a slightly modified version of your code:
I created a single workbook with three spreadsheets and two charts (on the first and second sheet). I debugged all the way until it created the first chart and got bored. Looks like it will work. What's different? Well, notice I commented out the following line:... $file = "C:\\testw.txt"; open (TTT, ">$file") || die "error"; $filename = "C:\\temp\\frufru.xls"; $filter = 'gif'; # 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 #why in the hell would you want to do this? #$hwnd = $Excel->{"Hwnd"}; #Hell no print TTT $hwnd; die "Cannot find $filename" unless (-e $filename); my $Book = $Excel->Workbooks->Open( $filename ); # open the file foreach my $Sheet (in $Book->Sheets) { ...
Grabbing the Windows handle to Excel is unnecessary since you already have a working one. I suspect you are using some deprecated example code.#$hwnd = $Excel->{"Hwnd"};
I also noticed some people made a few style points about this code. I will add a few also:
Celebrate Intellectual Diversity
|
|---|