PDA

View Full Version : VBA Fade in and out text + Loop



Skyhawk32803
02-14-2011, 06:10 AM
Hi All!

Attempting my first go at VBA within PPT, done a little in Excel before.. but I need some help on where to go with this one...

I have a list of a hundred or so strings, that I want to fade in and out, on the same slide after about 3 or secounds of displaying 1 at a time. And to keep doing it until stopped by the user ie CTRL + break. I have a a little of the coding so far, but not sure where to go from here...



Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Test()

'Start the presentation
ActivePresentation.SlideShowSettings.Run

'Change the value of the text box to String1 and fade in the text
ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text = "String1"
DoEvents

'Wait 2 secounds, fade out the Hello! Sting
Sleep 2000
'Fade in the new string.. String2!
ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text = "String2"
DoEvents

'A Loop to keep going back and forth between the 2 (there will be many more later....
'Until stoped by the user [CTRL + BREAK]
End Sub



I really appreciate any help the forum / people can provide.. thank you!!

Skyhawk

MWE
04-03-2011, 10:52 AM
Hi All!

Attempting my first go at VBA within PPT, done a little in Excel before.. but I need some help on where to go with this one...

I have a list of a hundred or so strings, that I want to fade in and out, on the same slide after about 3 or secounds of displaying 1 at a time. And to keep doing it until stopped by the user ie CTRL + break. I have a a little of the coding so far, but not sure where to go from here...



Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Test()

'Start the presentation
ActivePresentation.SlideShowSettings.Run

'Change the value of the text box to String1 and fade in the text
ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text = "String1"
DoEvents

'Wait 2 secounds, fade out the Hello! Sting
Sleep 2000
'Fade in the new string.. String2!
ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text = "String2"
DoEvents

'A Loop to keep going back and forth between the 2 (there will be many more later....
'Until stoped by the user [CTRL + BREAK]
End Sub


I really appreciate any help the forum / people can provide.. thank you!!

Skyhawkhave you tried using the custom animation feature built into PP? You have a fair amount of control over how things are done and may not need any VBA at all.