In the above code I am getting multiple results(and errors). Some time I could able to extract both the Excel Sheet into Powerpoint and some time I can extract just one xls and for the next one(xls) I got an Error "Can't call method "AddOLEObject" on an undefined value at C:\fg\Chartppt.pl line 37." and some time I got an error like "Can't call method "Activate" on an undefined value at C:\fg\Chartppt.pl line 24." Can any one please tell me why is it happen like that and how to over come this kind of errors. Thanks, Shaggyuse Win32::OLE; use Win32::OLE::Const 'Microsoft Office'; use Win32::OLE::Const 'Microsoft PowerPoint'; for($a=1;$a<3;$a++) { $power = Win32::OLE->GetActiveObject('Powerpoint.Application') || Win32::OLE->new('Powerpoint.Application', 'Quit'); $ppt = $power->Presentations->Add(); $ppt->{visible}=1; $xlapp = Win32::OLE->new('Excel.Application'); if($a==1) { $file = 'C:\fg\IMS\Chart for SW.xls'; $name = 'Chartsppt'; } else { $file = 'C:\fg\IMS\dms_data\Summary.xls'; $name='Summaryppt'; } $book = $xlapp->Workbooks->Open("$file"); $xlapp -> {Visible} = 1; for($i=1;$i<15;$i++) { $sheet = $book -> Charts($i); $sheet->Activate; $slide = $ppt->Slides->Add(1, ppLayoutBlank); $slide->Shapes->AddOLEObject({Left=>100, Top=>125, Width=>580, Height=>380, FileName=>$file ,}); } $filename = 'C:\fg\dms_data'; $ppt->SaveAs($filename . $name .'.ppt'); $ppt->Quit; $xlapp->Quit; }
In reply to Error in powerpoint extraction by shaggyquest
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |