Looping to control Controls

G

Guest

I have a text box on certain slides in my presentation (all are named
'VOTextBox') that I want to make visible = true or visible = false based on
user input. Initially I will start by making them all visible = false. I have
the following code in my module, with the expectation that PPT will return an
error if the active slide does not have a control by that name, but the error
trapping doesn't seem to work:

Sub VOTextOff()
Dim x As Long
On Error GoTo NoTextBox

For x = 1 To ActivePresentation.Slides.Count
ActivePresentation.Slides(x).Shapes("VOTextBox").Visible = msoFalse

NoTextBox:
Err.Clear
Next x

End Sub

Help is appreciated.
 
D

David M. Marcovitz

Try this instead:

Sub VOTextOff()
Dim x As Long
On Error GoTo NoTextBox
For x = 1 To ActivePresentation.Slides.Count
ActivePresentation.Slides(x).Shapes("VOTextBox").Visible =
msoFalse
Next x
NoTextBox:
Resume Next

End Sub


--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
D

David M. Marcovitz

Oh. In that case, combine John's solution and mine,a nd you should get
something that works.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
D

David M. Marcovitz

I was referring to my response that said:

Try this instead:

Sub VOTextOff()
Dim x As Long
On Error GoTo NoTextBox
For x = 1 To ActivePresentation.Slides.Count
ActivePresentation.Slides(x).Shapes("VOTextBox").Visible =
msoFalse
Next x
NoTextBox:
Resume Next

End Sub

If you use John's line in place of the ActivePresentation line, it should
work (but I only tested it with my line and regular autoshapes, not
John's line and control shapes).

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
S

Steve Rindsberg

I have a text box on certain slides in my presentation (all are named
'VOTextBox') that I want to make visible = true or visible = false based on
user input. Initially I will start by making them all visible = false. I have
the following code in my module, with the expectation that PPT will return an
error if the active slide does not have a control by that name, but the error
trapping doesn't seem to work:

Try this instead:

Sub VOTextOff()
Dim x As Long
On Error GoTo NoTextBox

For x = 1 To ActivePresentation.Slides.Count
ActivePresentation.Slides(x).Shapes("VOTextBox").Visible = msoFalse
Next

NormalExit:
Exit Sub

NoTextBox:
Resume Next

End Sub

OR:

Sub VOTextOff()
Dim x As Long
On Error Resume Next
For x = 1 To ActivePresentation.Slides.Count
ActivePresentation.Slides(x).Shapes("VOTextBox").Visible = msoFalse
Next
End Sub

Also, verify the names of the text box controls.
If you changed the name of the first one then copy/pasted to other slides, they
won't be named VOTextBox necessarily.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top