Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2011, 07:36 AM
Kevie192 Kevie192 is offline Powerpoint VBA: Help Needed Windows XP Powerpoint VBA: Help Needed Office 2010 32bit
Novice
Powerpoint VBA: Help Needed
 
Join Date: Dec 2011
Posts: 1
Kevie192 is on a distinguished road
Default Powerpoint VBA: Help Needed

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
Reply With Quote
  #2  
Old 12-13-2011, 08:28 AM
JohnWilson JohnWilson is offline Powerpoint VBA: Help Needed Windows 7 64bit Powerpoint VBA: Help Needed Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

You shouldn't have duplicate declarations in one module.

Try this using Select case
Code:
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
Dim Team1Scr As String
Dim Team2Scr As String
Select Case SSW.View.CurrentShowPosition

Case Is = 8
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

 
Case Is = 16
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
    
End Select
    
End Sub
A word of warning OnSlideShowPageChange is NOT a reliable method and not supported/documented by Microsoft. Before using it in an important setting try saving, close PowerPoint and reopen. Does it still work??

I've removed theSendKeys lines. What were they for? The effect would be to move on to the next slide or animation.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Serious help needed. karlyak22 Outlook 0 11-13-2011 07:32 AM
Powerpoint VBA: Help Needed Frontpage help needed ytryity Misc 1 03-19-2011 09:07 AM
Needed help with MSI Package ahaseeb Outlook 0 01-17-2011 10:19 PM
Powerpoint VBA: Help Needed help needed!!! thunder14 Word 1 10-17-2009 02:57 PM
Powerpoint VBA: Help Needed Help needed :) thechief55 PowerPoint 1 04-28-2009 01:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:38 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft