Hi monks,

I am having a problem setting the value of an object property using the Win32::OLE module. Hopefully you can help.

I have written a script that takes screen shots of a Powerpoint presentation. Unfortunately, if a slide has animation on it, the script doesn't wait for the animation to be completed before it takes its screen shot, thus they are sometimes incomplete.

There are three properties of the AnimationSettings object I believe I need to set to ensure the animation is switched off and thus the slide has all the shapes visible before the screen shot is captured.

These are: TextLevelEffect => ppTextLevelNone
EntryEffect => ppEffectNone
Animate => FALSE

According to the OLE/COM viewer, the constants I need above are activated by each property being set to 0.

The code below is a condensed version of my script, highlighting the problem.

#Global Powerpoint COM Objects. use Win32::OLE; my $PPt; my $PPtPresentation; my $PPtSSWindow; my $PPtSSView; $PPt = Win32::OLE->new("PowerPoint.Application") || die "Could not sta +rt PowerPoint.Application\n"; $PPtPresentation = $PPt->Presentations->Open( $filename ); $PPtSSWindow = $PPtPresentation->SlideShowSettings->Run(); $PPtSSView = $PPtSSWindow->View(); foreach my $shapes ( Win32::OLE::Enum->All($PPtSSView->Slide->{'Shapes +'} ) ) { my $animationSettings = $shapes->{'AnimationSettings'}; # ?set value like this? $animationSettings->{'TextLevelEffect'} = 0; $animationSettings->{'EntryEffect'} = 0; $animationSettings->{'Animate'} = 0; print "$animationSettings->{'TextLevelEffect'},"; print "$animationSettings->{'EntryEffect'},"; print "$animationSettings->{'Animate'}\n"; }
The output from the console is as follows:
Win32::OLE(0.1502) error 0x80020009: "Exception occurred" in PROPERTYPUT "EntryEffect" at pdp_ppt.pl line 429 0,257,0 OLE exception from "Microsoft PowerPoint 2000":
This is repeated for each shape on a slide. It indicates I only need to set the EntryEffect property for this particular presentation, as this property is set to 257 for each shape (ppEffectCut constant), the other two properties are set to 0.

Any help you can offer to successfully set the const values of these properties will be gratefully received. Cheers, Steve


In reply to Win32 OLE: setting an object property value by Anonymous Monk

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.