Auto_NextSlide Help Needed

Y

Yogi_Bear_79

I have a simple test SlideShow. It contains two slides, I installed the
AutoEvents Addin. I created a module and entered the following code, but
nothing appears on the second slide. I haven't added anything to the slide
(it is blank). I had hoped this code would add a text box with that
statement in it. I looked at adding a text box manually, but found no way to
identify it. I also tried just trigering a simple MsgBox but that didn't
work either. I also tried a Selcet Case statement.

The end results will be I need to display an updated Text box on this slide
whenever it appears during the slide show loop. The text to be displayed
will be determined byVBA code.

Sub Auto_NextSlide(Index As Long)

If (Index = 2) Then
With ActivePresentation.Slide(2).Shapes("MyWeirdLittleTextBox")
.TextFrame.TextRange.Text = "Hi. I'm different now."
End If
 
Y

Yogi_Bear_79

First, make sure that the event is triggering your macro. Add a
breakpoint in
the IDE or add a msgbox or whatever works for you.

Next, it should be ActivePresentation.Slides(2) (Slides, not Slide --- my
goof, sorry about that)

You'd need to set the text box's .Name property to "MyWeirdLittleTextBox"
ahead
of time for this to work.

Edit the name of a shape
http://www.rdpslides.com/pptfaq/FAQ00584.htm

And there needs to be an End With prior to End If
Ok, yeah I found a couple of my mistakes after I posted. First off from time
to time I have to go to Tools > Auto Events and turn it back on. I created a
text box from the control toolbar wit the name TextBox1, I have the
following code in a module. When the with statement is removed the MsgBox
appears. When the With statement is included I get an "invalid or
unqualified reference" on the .TextFrame.......line. So with that said I
know the trigger works, and I know it catches Slide 2, now just need to get
my Text to display in the TextBox.

Sub Auto_NextSlide(Index As Long)

If (Index = 2) Then
MsgBox "HELLO"
With ActivePresentation.Slides(2).Shapes("TextBox1")
.TextFrame.TextRange.Text = "Hi. I'm different now."
End With
End If

End Sub

I looked at the website you referenced. Is that the way I need to name the
shape, or am I ok, by creating it from the controls toolbar, and nameing it
under it's properties. I ask this because, I know of no way t create a
textbox that will stay on the slide without at lease one char in it.
 
Y

Yogi_Bear_79

Steve Rindsberg said:
Right ... it's expecting a text box shape, not an OLE control. Try it
with a
standard PPT text box instead. If you really really need to use an ole
text
control for some reason, let me know.

So with that said I

Ah. So that's why the OLE control.

You could create a regular text box but put a space character in it.
Invisible
but there. Or, since you'll run this at startup before anyone sees the
slide,
the text box could have any "dummy" text you like; it'll get replaced
before
it's visible.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================

Thanks for your help. The completed rough draft is below, it does what it is
intended to do. I have to clean the code some more, and add a few features,
but it does what I set out to. I needed to add a slide in my public
rollingshow that showed the days, hours, min remaining until a specifi
event. With your help, I now have this. Basically it's a countdown.
Everytime this slide is displayed it shows up to the minute how long until
an event is. I will tweak the code some more, to make it smoother, and add
a few features, for example when days reach zero, it will no longer display
days, etc...thanks again!

Sub Auto_NextSlide(Index As Long)
a = "4/21/06 11:00:00AM"

If (Index = 2) Then
b = Day(a) - Day(Now())
c = Hour(a) - Hour(Now())
d = Minute(a) - Minute(Now())

If (c < 0) Then
c = c + 24
b = b - 1
End If

If (d < 0) Then
d = d + 60
c = c - 1
End If

With ActivePresentation.Slides(2).Shapes("TextBox1")
.TextFrame.TextRange.Text = "Days " & b & ", Hours " & c & ",
Minutes " & d
End With


End If

End Sub
 
Top