Solved

PowerPoint 2007 events

Posted on 2011-09-03
3
378 Views
Last Modified: 2012-06-22
I have added an ActiveX webbrowser control to a slide.  I'd like it to navigate to a local file as soon as the presentation starts, but I am having trouble figuring out how to use events to trigger action.

This has been my reference:
http://msdn.microsoft.com/en-us/library/bb265913(v=office.12).aspx

I cannot figure out how to auto-run the InitializeApp sub.

From the msdn link:
To create an event handler for an event of the Application object, you need to complete the following three steps:
1.Declare an object variable in a class module to respond to the events.
2.Write the specific event procedures.
3.Initialize the declared object from another module(this is the InitializeApp sub below)


To create an event handler for an event of the Application object, you need to complete the following three steps:
1.Declare an object variable in a class module to respond to the events.
2.Write the specific event procedures.
3.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 is 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 Office PowerPoint Application object, and the event procedures in the class module will run when the events occur.

Open in new window

0
Comment
Question by:motokent
3 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 250 total points
Comment Utility
Unfortunately, PPT is not fully compatible with htis and to do as you want requires an add-in.   Via an add-in you can detect events, one of which is initialise on open.

See http://skp.mvps.org/autoevents.htm for an appropriate add-in and guide.

Chris
0
 
LVL 23

Assisted Solution

by:JSRWilson
JSRWilson earned 250 total points
Comment Utility
In 2007 and 2010 you can auto run the initializeApp sub by using the onLoad of the ribbon when the presentation is loaded. Not entirely reliable though.

See http://www.pptalchemy.co.uk/PowerPoint_Auto_Open_Code.html for more

0
 

Author Closing Comment

by:motokent
Comment Utility
Thanks both of you.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now