Help with VBA

E

EBWired

There's a great VBA from pptools.com that I've successfully used for a few
years now (below). Essentially, it'll help toggle text on and off with a
mouse click, and I usually use it for multiple buttons on a single slide
(e.g. for a game). But recently I can't toggle. The first click over the
button will show/hide text, but the second click takes me to the next slide.
And after playing around with keyboard stuff, the code will only work
properly for me if I press tab at the same time I do a left mouse click over
the action button (i.e. it will toggle text correctly rather than go to the
next slide). I never had to press tab before (nor do I want to during
presentations).

Can someone help me troubleshoot? I have PowerPoint 2007 running on Vista.
Thanks.


*****************************
Sub Peekaboo(oSh As Shape)
' Hides/makes visible the shape's text

With oSh.TextFrame.TextRange
' If it has text ...
If Len(.Text) > 0 Then
' Store the text in a tag so we can retrieve it later
oSh.Tags.Add "PeekabooText", .Text
' Now blank the text
.Text = ""
Else
.Text = oSh.Tags("PeekabooText")
End If
End With

End Sub

Sub ResetPeekaboos()
' Resets the shapes with peekaboo text to make the text invisible

Dim oSh As Shape
Dim oSl As Slide

For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
If Len(oSh.Tags("PeekabooText")) > 0 Then
oSh.TextFrame.TextRange.Text = ""
End If
Next ' oSh
Next ' oSl

End Sub

Sub UnhidePeekaboos()
' Resets the shapes with peekaboo text to make the text visible

Dim oSh As Shape
Dim oSl As Slide

For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
If Len(oSh.Tags("PeekabooText")) > 0 Then
oSh.TextFrame.TextRange.Text = oSh.Tags("PeekabooText")
End If
Next ' oSh
Next ' oSl

End Sub

Sub HidePeekaboos()
' Resets the shapes with peekaboo text to make the text invisible
' You must have activated the text as peekaboo one time for this to work

Dim oSh As Shape
Dim oSl As Slide

For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
If Len(oSh.Tags("PeekabooText")) > 0 Then
oSh.TextFrame.TextRange.Text = ""
End If
Next ' oSh
Next ' oSl

End Sub
 
E

EBWired

Hi Steve,

Yes, everything was working with my system and I'm not sure what changed.
My macros are enabled, and when I do a dummy test on a new presentation, the
same glitch occurs. I have a feeling it's probably with my settings, but I
just don't know why or where to start. Does that tab+left mouse click give
you a clue?

On two sidenotes, I didn't realize I would reach the same person with this
problem, so that's great. Second, I see that you'll be in San Diego where I
live, but it's too bad that I'll be out of town this weekend. Maybe I can
check out what pptlive is all about next Tue or Wed!
 
E

EBWired

Hi John,

Thanks for explaining what the tab key does (it's not the Alt from what I
see). I experimented and yes, if I tab to each action button and press
Enter, then the toggle VBA works. I'll also look into the mouse settings
some more since I had a hard time figuring it out right away.

I wonder if MS changed something through its updates so that the VBA doesn't
work with the mouse anymore? It's frustratingly weird.

And I would've responded earlier. I didn't know you replied to my post.
Thanks again!
 
E

EBWired

At first try, the code worked. And so the universe is back to normal again.
Let's just hope that once I fix the old PPT files that they'll be fine.

Steve, you and John rock, and so thank you very much for help with this.
 

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