SweetingA
asked on
Problems with powerpoint vba initialising APP
I have tried to follow the guidance provided on the Microsoft website for event handling but i can not get the following to code work.
I have a classmodule called "EventClassModule" - includes the following code
Public WithEvents App As PowerPoint.Application
Private Sub App_PresentationOpen(ByVal Pres As Presentation)
ActivePresentation.Slides( 12).Shapes ("TextBox1 ").OLEForm at.Object. Text = "Basic introduction to training"
End Sub
I have a module called "Module1" includes the follwoing code
Dim X As New EventClassModule
Sub InitializeApp()
Set X.App = PowerPoint.Application
End Sub
And i was hoping that when i open the ppt file the text box on page12, textbox1 will be populated but it simply does not work and does not error.
I am obviously doing something very stupid (like where and how do i run initializeapp), all help most welcome
I have a classmodule called "EventClassModule" - includes the following code
Public WithEvents App As PowerPoint.Application
Private Sub App_PresentationOpen(ByVal
ActivePresentation.Slides(
End Sub
I have a module called "Module1" includes the follwoing code
Dim X As New EventClassModule
Sub InitializeApp()
Set X.App = PowerPoint.Application
End Sub
And i was hoping that when i open the ppt file the text box on page12, textbox1 will be populated but it simply does not work and does not error.
I am obviously doing something very stupid (like where and how do i run initializeapp), all help most welcome
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rgonzo is telling you (correctly) that it is very difficult to fire the sub to initialise the event object from a normal presentation. The only reliable sub that fires is Auto_Open BUT it will only fire when an ADDIN loads. The ADDIN cannot contain your slides.
If this is a pptm file AND you are sure the user is opening in edit mode and Macro security is set low enough you can use the ribbon onLoad Event from XML. You may not even need the class module.
There's a simple tutorial on how to add this XML to the presentation.
http://www.pptalchemy.co.uk/PowerPoint_Auto_Open_Code.html
In the presentation
Sub OnLoadCode()
ActivePresentation.Slides( 12).Shapes ("TextBox1 ").OLEForm at.Object. Text = "Basic introduction to training"
End Sub
If you can wait for the show to begin before changing the ActivX text then it is easier!
Probably good to explain WHY the text has to be changed too.
If this is a pptm file AND you are sure the user is opening in edit mode and Macro security is set low enough you can use the ribbon onLoad Event from XML. You may not even need the class module.
There's a simple tutorial on how to add this XML to the presentation.
http://www.pptalchemy.co.uk/PowerPoint_Auto_Open_Code.html
In the presentation
Sub OnLoadCode()
ActivePresentation.Slides(
End Sub
If you can wait for the show to begin before changing the ActivX text then it is easier!
Probably good to explain WHY the text has to be changed too.
ASKER
sorry i am a real dummy and a new starter to this.
Can you explain the procedure right from the start as i may have other things set wrong.
Sorry to be a pest.
Thanks