Hi all,
use 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 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, Shaggy

In reply to Error in powerpoint extraction by shaggyquest

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.