Powerpoint VBA: Help Needed

Kevie192

New Member
Joined
Oct 2, 2009
Messages
17
Hi all,

I'm trying to write some code to update a scoreboard on a few slides of a presentation using VBA but I'm getting a bit stuck and wondered if anyone can see what I'm doing wrong?

This part works absolutely fine:

Code:
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
 
    If SSW.View.CurrentShowPosition = 8 Then
Dim Team1Scr As String
Dim Team2Scr As String
Team1Scr = InputBox("Enter Team 1 Score:", "Scores")
ActivePresentation.Slides(8).Shapes("Scr1").TextFrame.TextRange.Text = Team1Scr
Team2Scr = InputBox("Enter Team 2 Score:", "Scores")
ActivePresentation.Slides(8).Shapes("Scr2").TextFrame.TextRange.Text = Team2Scr
SendKeys ("{ENTER}")
 
End If
    
End Sub

But, I need events for more than one slide, so I've tried adding in an ElseIf and it now doesn't show the boxes on any of the slides:

Code:
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
 
    If SSW.View.CurrentShowPosition = 8 Then
Dim Team1Scr As String
Dim Team2Scr As String
Team1Scr = InputBox("Enter Team 1 Score:", "Scores")
ActivePresentation.Slides(8).Shapes("Scr1").TextFrame.TextRange.Text = Team1Scr
Team2Scr = InputBox("Enter Team 2 Score:", "Scores")
ActivePresentation.Slides(8).Shapes("Scr2").TextFrame.TextRange.Text = Team2Scr
SendKeys ("{ENTER}")
 
ElseIf SSW.View.CurrentShowPosition = 16 Then
Dim Team1Scr As String
Dim Team2Scr As String
Team1Scr = InputBox("Enter Team 1 Score:", "Scores")
ActivePresentation.Slides(16).Shapes("Scr1").TextFrame.TextRange.Text = Team1Scr
Team2Scr = InputBox("Enter Team 2 Score:", "Scores")
ActivePresentation.Slides(16).Shapes("Scr2").TextFrame.TextRange.Text = Team2Scr
SendKeys ("{ENTER}")
    
End If
    
End Sub

Any ideas?

Many thanks,

Kevin
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,225,609
Messages
6,185,969
Members
453,333
Latest member
BioCoder84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top