Application Events in Powerpoint

G

Guest

It seems there's a catch-22 for application events in PowerPoint. If I
understand the documentation correctly, they aren't automatically enabled, so
you have to create the object with events and initialize it. But any event
that would do that automatically would have to rely on an event to run, which
can't be done until after it's been run. The only way I've found to handle
this is to force a button or something to be hit. This is really kludgy,
messes up the graphics, and is bad for a presentation that's going to be
distributed. It certainly shouldn't be the business of, say, some salesguy
out in the field to understand that there's an application object that needs
to be initialized in the presentation.

I feel like I must be missing something, since it makes no sense. It's like
a driving school saying, "You can't learn to drive until you've passed your
driving test," and no one would intentionally set that up. Hence my doubt...

Any thoughts?
Thanks!
BnB
 
T

Tushar Mehta

In PP, the Auto_Open and the complementary Auto_Close events fire
automatically in a *add-in,* i.e., in a .PPA file. You can use them to
do whatever else you want. For more, search www.pptfaq.com for
'auto_open' (w/o the quotes).

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
S

Steve Rindsberg

It seems there's a catch-22 for application events in PowerPoint. If I
understand the documentation correctly, they aren't automatically enabled, so
you have to create the object with events and initialize it. But any event
that would do that automatically would have to rely on an event to run, which
can't be done until after it's been run. The only way I've found to handle
this is to force a button or something to be hit. This is really kludgy,
messes up the graphics, and is bad for a presentation that's going to be
distributed. It certainly shouldn't be the business of, say, some salesguy
out in the field to understand that there's an application object that needs
to be initialized in the presentation.

If you're trying to use events in VBA that's part of a presentation, then yes,
it's going to be a bit kludgy. The implementation is designed more for use in
addins.

The simplest way I've heard of firing them off is to use an action setting,
though not necessarily attached to a button, as you describe. The graphics
themselves, or really anything on the slide, can have an action setting that
launches the macro that initializes the event handler.
 
G

Guest

Ah, that's a good idea. I'll do that with a MouseOver event and a boolean to
ensure it only runs once. I am trying to do events in a presentation (other
uses don't come to mind, but clearly they exist). It can be used as an
extension to animation. Animation tends to be very time-directional, and
macros can be less so. It wasn't worth doing the whole add-in thing.

I only wish that animation sequences could be triggered by a macro (in this
condition, fire this sequence; in that condition fire a different one), but
there doesn't seem to be any slide-show-time link between macros and
timelines... Not to mention the fact that shape numbering is completely
disconnected between animation and macro objects (and finding the shape
numbers in either case is kludgy).

Presentation time is also not a robust environment; when I bring dialog
boxes up, sometimes they show up, sometimes not unless I restart PP. If you
show the File Browse dialog, it suddenly switches out of show mode to display
it, and when you close it you have to click back into show mode. Kinda breaks
the flow. I figure not many people try to do this since it seems so untested.

Thanks!
BnB
 
S

Steve Rindsberg

Ah, that's a good idea. I'll do that with a MouseOver event and a boolean to
ensure it only runs once. I am trying to do events in a presentation (other
uses don't come to mind, but clearly they exist). It can be used as an
extension to animation. Animation tends to be very time-directional, and
macros can be less so. It wasn't worth doing the whole add-in thing.

That's perfectly understandable.
I only wish that animation sequences could be triggered by a macro (in this
condition, fire this sequence; in that condition fire a different one), but
there doesn't seem to be any slide-show-time link between macros and
timelines... Not to mention the fact that shape numbering is completely
disconnected between animation and macro objects (and finding the shape
numbers in either case is kludgy).

Shape numbering/naming has its own sometimes-peculiar logic. I think what you're
probably seeing is a side effect of this:

PowerPoint names each shape as it's created.
Each shape has a .Name property
That .Name property is set to the PPT-assigned name by default but we can change it.
Macros can use the .Name property of a shape to access it but the animation dialogs
still show the PPT-assigned name.

Annoying at best.
Presentation time is also not a robust environment; when I bring dialog
boxes up, sometimes they show up, sometimes not unless I restart PP. If you
show the File Browse dialog, it suddenly switches out of show mode to display
it, and when you close it you have to click back into show mode. Kinda breaks
the flow. I figure not many people try to do this since it seems so untested.

Got some sample code you could post that demonstrates this?
 
B

Brian Reilly, MS MVP

BnB
The MouseOver attached to a full frame no fill/no line shape would do
the trick, but it is only bullet proof if the slide show is set up in
Kiosk mode. But then you need forward and back buttons in that case.

Brian Reilly, MVP
 
G

Guest

Here's some sample code. The first is a routine that executes to bring up a
dialog (as a MouseClick ActionEvent). It was intended to be complete,
loading/showing, then unloading when done. What would happen is that the
first time it ran, the dialog would show; the next time it wouldn't. (This
was not ALWAYS the case, but more often than not.) You'll note below that I
commented the unload instruction; this seemed to fix the situation. Which
means that it realistically could only load once reliably, then it got
confused. So what's posted below works, but would be cleaner with the unload
intact.

BTW, OffloadForm.Valid is simply a property I give to the UserForm to
indicate that the form contents when closed should be acted on.

Skip beyond this to see the Browse dialog code.

Public Sub DoOffload()

Load OffloadForm
OffloadForm.Show
If OffloadForm.Valid Then
If OffloadForm.AsynchOption Then
Application.ActivePresentation.Slides(3).Shapes("Group
98").Visible = msoTrue
Application.ActivePresentation.Slides(3).Shapes("Group
115").Visible = msoTrue
Else
Application.ActivePresentation.Slides(3).Shapes("Group
103").Visible = msoTrue
Application.ActivePresentation.Slides(3).Shapes("Group
127").Visible = msoTrue
End If
End If

'Unload OffloadForm
ClearMenuHighlights
HideMenu

End Sub

The Browse dialog issue is such that when the dialog runs, it comes up, but
pops PPT out of show mode.

Private Sub BrowseButton_Click()
Dim lDialog As FileDialog

Set lDialog = Application.FileDialog(msoFileDialogFilePicker)
If lDialog.Show = -1 Then Me.RTLFileBox = lDialog.SelectedItems(1)

Set lDialog = Nothing

End Sub
 
S

Steve Rindsberg

I'd be inclined to try a Windows common dialog box rather than relying on PPT's
interal one. Have you tried that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top