Share via

Catch onclick event

Anonymous
2011-06-25T06:41:04+00:00

Hello,

I want a VBA program to start on onclick event (e.g. when left button of mouse is pressed or when space button is pressed and so on). How can I do it?

Will it be possible to cancel that event with VBA, in other words, will I be able when some conditions are met to cancel switching to another slide after space button is pressed?

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-06-26T11:37:46+00:00

As Steve says it's not easy to instantiate the event class object when the presentation loads and the code is best put in an AddIn.However it is possible to make the code required run when a presentation opens by adding an onLoad event to the XMLin 2007 / 2010 only.

You need to note however some problems:

  1. The onLoad event refers to the RIBBON. No ribbon loads = no event (in particular ppsm files opening direct to show mode will not fire it.)
  2. You need to be sure that macros are enabled by the user.

I'm not quite sure I understand what you need but If you want the slide 3 >> slide 4 transition locked until a button is clicked then I have uloaded asimple demo.

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
2011-06-25T18:50:15+00:00
  1. How to start event handler when presentation begins? At the moment I need to press the button to start it.

Other than triggering it via a button or some other action that triggers a macro, you can't.

Instead, you'd have the event handling code in an add-in (which would require that the user keep the add-in loaded).

2) SlideShowNextClick activates after switching to other slide is made or after effect is completed. Is there any other event which activates before switching to the other slide is made or before effect to the object is applied?

Not sure, but your code might well run more quickly than PPT can redraw the next screen.  Perhaps you could immediately return the user to the previous slide.

>> 3) Is it possible to cancel spacebar, arrow keys etc with VBA? E. g. there is a presentation of 5 slides, when slide #3 is reached, spacebar, arrow keys, mouse clicks do not work for switching to slide #4 (VBA is somehow blocking it), but if I press a button within slide #3 I am allowed to continue to other slides with spacebar, arrow keys etc.

Set the presentation to run in Kiosk mode.  Then the only way the user will be able to change slides is via hyperlinks and action settings that you provide in the presentation itself.

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-06-25T13:37:16+00:00

    Thanks for that. Three questions:

    1. How to start event handler when presentation begins? At the moment I need to press the button to start it.

    2) SlideShowNextClick activates after switching to other slide is made or after effect is completed. Is there any other event which activates before switching to the other slide is made or before effect to the object is applied?

    1. Is it possible to cancel spacebar, arrow keys etc with VBA? E. g. there is a presentation of 5 slides, when slide #3 is reached, spacebar, arrow keys, mouse clicks do not work for switching to slide #4 (VBA is somehow blocking it), but if I press a button within slide #3 I am allowed to continue to other slides with spacebar, arrow keys etc.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-06-25T11:48:19+00:00

    Do you know how to catch events in PowerPoint? It's not straightforward.

    Assuming you do the SlideShowNextClick event should be what you need. It will also trap the spacebar, arrow keys etc in show mode I think.

    Was this answer helpful?

    0 comments No comments