Solved

PowerPoint 2007 events

Posted on 2011-09-03
3
379 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
ID: 36479502
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
ID: 36480019
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
ID: 36480199
Thanks both of you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Perhaps more familiar to developers who primarily use VBScript than to developers who tend to work only with Microsoft Office and Visual Basic for Applications (VBA), the Dictionary is a powerful and versatile class, and is useful …
Problem: You created a new custom form in Outlook for your contacts (added fields, deleted fields, changed the layout of fields, whatever) and made it the default form for contacts. The good news is that all new contacts will utilize the new form. T…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

895 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

14 Experts available now in Live!

Get 1:1 Help Now