Log in

View Full Version : Macro to Activate Spreadsheet in PP



beckieo
06-30-2011, 08:42 AM
Working with PP 2007, I have an enbedded spreadsheet that calculates number of days since a specific date. (=Now()-09/11/10)
Of course, the numbers only update if I select the spreadsheet on the slide.
I need the calculations to happen every time the slideshow is run.

I've figured out the code I need to run a macro in PP on startup.
This code works, when I run the slide show:


Sub OnSlideShowPageChange()
Dim i As Integer
i = ActivePresentation.SlideShowWindow.ViewCurrentShowPosition
If i <> 1 Then Exit Sub
MsgBox "Your Code goes here"
End Sub


I figured out how to record a PP macro, (since I'm pretty inexperienced with writing code) and recorded a macro where I select the spreadsheet, causing it to update, then de-select the spreadsheet.
Unfortunately, when I try to substitute this code for the "MsgBox "Your Code goes here" above, it doesn't work. The line in red errors out and stops the macro.


Sub OnSlideShowPageChange()
Dim i As Integer
i = ActivePresentation.SlideShowWindow.ViewCurrentShowPosition
If i <> 1 Then Exit Sub

ActiveWindow.Selection.ShapeRange.OLEFormat.DoVerb Index:=1
Application.WindowState = ppWindowMaximized
Application.WindowState = ppWindowMaximized
Application.WindowState = ppWindowMaximized
Application.WindowState = ppWindowMaximized
End Sub

Any idea what I'm doing wrong?

Thanks for looking,
BeckieO

John Wilson
06-30-2011, 09:11 AM
The code you are using to run the macro when the show starts is very unreliable (yes I know I wrote it!). Try saving and reopening and then run the show on a few different PCs and see if it fires. Do check this carefully because it is very likely to fail at times. It's very difficult to trap the slide show page change event properly except in an AddIn.

Even if this can be made to work the second code will never work. There is no way to select objects in show mode so anything with selection will always fail.

If you know the name of the shape

SlideShowWindows(1).View.Slide.Shapes ("name here").OLEFormat etc might do it. (this is top of head code and untested) you would also need to change "If i <>1" to "If i <> the slide number with the chart"

beckieo
06-30-2011, 09:15 AM
Thanks for the quick response. I'll give it a whirl and let you know how it comes out.

John Wilson
06-30-2011, 09:17 AM
Notice I have added an edit

i<> slide number with chart

mooseman
01-16-2012, 02:49 PM
Working with PP 2007, I have an enbedded spreadsheet that calculates number of days since a specific date. (=Now()-09/11/10)
~
I figured out how to record a PP macro, (since I'm pretty inexperienced with writing code) and recorded a macro where I select the spreadsheet, causing it to update, then de-select the spreadsheet.


Could you tell me how you did these two things in PPT 2007?
Mostly, how did you deselect the embedded spreadsheet?
Do you only have one of these in your presentation?
Thanks