PDA

View Full Version : Non-click, non-mouse originated trigger?



rainerfeyer
02-29-2008, 11:40 AM
Hi all,

I have found certain triggers which can be used in PP coding, such as onclick() or onMouseover().

are there any functions such as 'onload()', or 'onSlideactive()' or something like that? I wish to add coding to a slide which will happen once the slide activates, not having to have user input,

thanks

rainer

Brandtrock
02-29-2008, 05:50 PM
PowerPoint events are a bit different than Excel or Word events. They get declared in a Class module as follows from the Help files

Using Events with the Application Object

See Also Specifics
To create an event handler for an event of the Application (http://www.vbaexpress.com/forum/ppobjApplication1.htm) object, you need to complete the following three steps:
Declare an object variable in a class module to respond to the events.
Write the specific event procedures.
Initialize the declared object from another module.Declare the Object Variable

Before you can write procedures for the events of the Application object, you must create a new class module and declare an object of type Application with events. For example, assume that a new class module is created and called EventClassModule. The new class module contains the following code.
Public WithEvents App As Application
Write the Event Procedures

After the new object has been declared with events, it appears in the Object list in the class module, and you can write event procedures for the new object. (When you select the new object in the Object list, the valid events for that object are listed in the Procedure list.) Select an event from the Procedure list; an empty procedure is added to the class module.
Private Sub App_NewPresentation()

End Sub
Initializing the Declared Object

Before the procedure will run, you must connect the declared object in the class module (App in this example) with the Application object. You can do this with the following code from any module.
Dim X As New EventClassModule
Sub InitializeApp()
Set X.App = Application
End Sub
Run the InitializeApp procedure. After the procedure is run, the App object in the class module points to the Microsoft PowerPoint Application object, and the event procedures in the class module will run when the events occur


The list below is from the drop down once the class module is created.
The following events are available:

AfterNewPresentation(ByVal Pres As Presentation)
AfterPresentationOpen(ByVal Pres As Presentation)
ColorSchemeChanged(ByVal SldRange As SlideRange)
NewPresentation(ByVal Pres As Presentation)
PresentationBeforeSave(ByVal Pres As Presentation, Cancel As Boolean)
PresentationClose(ByVal Pres As Presentation)
PresentationNewSlide(ByVal Sld As Slide)
PresentationOpen(ByVal Pres As Presentation)
PresentationPrint(ByVal Pres As Presentation)
PresentationSave(ByVal Pres As Presentation
PresentationSync(ByVal Pres As Presentation, ByVal SyncEventType As Office.MsoSyncEventType)
SlideSelectionChanged(ByVal SldRange As SlideRange)
SlideShowBegin(ByVal Wn As SlideShowWindow)
SlideShowEnd(ByVal Pres As Presentation)
SlideShowNextBuild(ByVal Wn As SlideShowWindow)
SlideShowNextClick(ByVal Wn As SlideShowWindow, ByVal nEffect As Effect)
SlideShowNextSlide(ByVal Wn As SlideShowWindow)
WindowActivate(ByVal Pres As Presentation, ByVal Wn As DocumentWindow)
WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As Boolean)
WindowBeforeRightClick(ByVal Sel As Selection, Cancel As Boolean)
WindowDeactivate(ByVal Pres As Presentation, ByVal Wn As DocumentWindow)
WindowSelectionChange(ByVal Sel As Selection)


I'm not as familiar with PowerPoint as I am with Excel, so we may be learning as we go here, but I hope this gives you a start.

Regards,

gwkenny
02-29-2008, 09:45 PM
Look in the help files for SlideShowNextSlide Event

:D

John Wilson
03-01-2008, 05:52 AM
While the above is the best way to go PowerPoint can react to the new slide in a slide show using

Sub OnSlideShowPageChange()
'Do something
End SubIt is a little flaky though and you may need to call it manually once and then it should fire with every new slide.

rainerfeyer
03-03-2008, 10:39 AM
Thank you both very much for the information!!!

Two minor questions:
When one declares the class/ procedure - does this have to happen on each computer on which the specific power point presentation is run, or is the 'initialization' process coded into the PPT/ PPS itself?

Also, the function 'OnSlideShowPageChange()': Where can I place this function (I apologize if these are ignorant questions, but I have tried several functions which did not react)? Is it feasible to open Microsoft Script editor and inserting the function in the <Head> portion?

Again, thank you - this is helping immensely!

John Wilson
03-03-2008, 10:56 AM
Have a look in the kbase on this site. Search for PowerPoint applications and there are examples of both these techniques. If you use the OnSlideShowPageChange idea I would have an action button on slide one that the user presses to start the show. Give it an action of Run Macro. Once the macro has run once it will fire with every new page.

speechpath
03-03-2008, 07:20 PM
I'm VERY new to VB and the descriptions you all gave are over my head. Can anyone simplify them for me?

Rob

rainerfeyer
03-05-2008, 07:58 AM
Thank you very much!

Rainer

Vivian66
06-21-2010, 02:28 AM
This is really a good place to study. Thanks for all!