Foggy Bottoms has asked for the wisdom of the Perl Monks concerning the following question:

Here's my problem : I want to scan various sorts of documents and retrieve information from each one of them. For instance, I scan a word document and retrieve basic document properties as well as the text in the file. However it's not so easy with PowerPoint. I'm having trouble trying to access information (ie shapes according to the MSDN) included in a specific slide. Does anyone have a clue on how to proceed ?

Thanks.
  • Comment on How can I access data included in a ppt slide ?

Replies are listed 'Best First'.
Re: How can I access data included in a ppt slide ?
by phydeauxarff (Priest) on Jun 05, 2003 at 14:56 UTC
Re: How can I access data included in a ppt slide ?
by fglock (Vicar) on Jun 05, 2003 at 19:26 UTC

    You can download the ppt specs at http://www.wotsit.org (search for "ppt").

    The document is a zipped html directory.

    Appendix 3 is specially interesting: "Sample code to read the text out of a PowerPoint '97 presentation." (in C++)

    If you make a Perl version of this, it would be nice if you could submit it to CPAN!

      Well so far, I've managed to do easy things thanks to the MSDN such as adding slides (where and which exact type) and drawing text areas, shapes, labels... However, I can't seem to add text : one of the VB syntaxes (there's several ways apparently) MS provides is the following :
      Set oTitle = ActivePresentation.Slides(2).Objects.Title
      This would be the VB code (according to MSDS). I assume the perl code would be :
      $ppt->ActivePresentation->Objects->Slides($nb)->Title->Text = "TaGaDa"
      where $ppt is
      $ppt = Win32::OLE->GetActiveObject(MSPPT.'.Application') and works just fine.
      However, Perl doesn't seem to know what objects. is and returns the following error :
      Can't call method "Slides" on an undefined value at D:\source\powerpoint.pl line 23.
      MSDSN reference is here :
      http://www.msdn.microsoft.com/library/en-us/dnpower97/html/ppppt_w95.asp?frame=true#ppppt_w95_work

      If u have any idea, let me know, thanks !!!

        You can use "QueryObjectType" for debugging.
        Print the object type for "$ppt", and the object type of "$ppt->ActivePresentation" and check if they are what you expected.

        Win32::OLE->QueryObjectType(OBJECT) The QueryObjectType() class method returns a list of the type library name and the objects class name. In a scalar context it returns the class name only. It returns undef when the type information is not available.