Capturing text from stacked rectangles; mouseover and click events

K

Keith R

I have 4 stacked rectangles that are all the same size, which have
textframes in them.

When a user clicks on the topmost (and therefore visible) rectangle, I send
it "to back" to reveal the next rectangle below. A user can cycle through
these 4 boxes as many times as needed. I'm using Shyam's code at
http://www.mvps.org/skp/ppt00040.htm#2

Now I'd like to take the text of a newly revealed rectangle and put it on a
second slide, so that the user can see the text in a larger font than will
fit in the source rectangle.

I used the mouseover event to get the text from the rectangle that gets
revealed, without clicking on it (because that would send that box to the
back).

I only want the text of the rectangle that gets revealed, so I created a
global variable that "locks" once it has that first set of text. As soon as
the top rectangle dissapears, it fires the mouseover event for the
rectangle below and gives me the first messagebox (see code below) with the
correct text in it, but the rest of the code does not seem to be working- I
welcome any ideas or feedback on how to accomplish this...

thanks,
Keith R


Public TextCaptured As Boolean
'------------------------------------------------

Sub GrabText(oShp As Shape)
Dim NewText As String

If TextCaptured = False Then
NewText = oShp.TextFrame.TextRange
MsgBox NewText

ActiveWindow.View.GotoSlide Index:=2
' it never goes to slide 2-
' is this some kind of interaction with the mouseover event?

MsgBox "1" 'testing to see if the code got this far, but it never fires
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
MsgBox "2" 'never fires
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
MsgBox "3" 'never fires
ActiveWindow.Selection.TextRange.Text = NewText

TextCaptured = True
End If
End Sub
 
B

B

You could be a little creative on the designing side and save yourself some
programming headaches.

Make a tag labeled "Text" for each of the text boxes. Make that text the
same as the text in the next box.

Box 1 Text = Tag for Box 4
Box 2 Text = Tag for Box 1
Etc.

Now you can use this line of code
varNextText = oShp.Tags("Text")
to simplify your life.

B
 
K

Keith R

ok, now I have a newbie question ;-)

I found the tags property in VBA, but where can I set this in the main PP
environment?

I have 30 sets of the 4 stacked boxes, (120 shapes total) and they aren't
necessarily
in order, so it would be a nightmare to try to assign the tag property from
VBA because
I'd have to sift through each shape and either name them all, or figure out
where each
default number landed where... how can I set the tag property within PP?
 
B

B

There is more then one way to look at this.
Try the code below

'>>>>>>> Start Code <<<<<<<<<
Sub WhatsOnTop()
Dim X As Integer
Dim Dummy As String
Dim Topmost As Integer
Dim oSld As Slide

Set oSld = ActivePresentation.Slides _
(SlideShowWindows(1).View.CurrentShowPosition)

For X = 1 To oSld.Shapes.Count
With oSld.Shapes(X)
If .Type = msoTextBox Then
If .ZOrderPosition > Topmost Then
Topmost = .ZOrderPosition
Dummy = .TextFrame.TextRange.Text
End If
End If
End With
Next X

Set oSld = Nothing
MsgBox Dummy

End Sub
'>>>>>>> End Code <<<<<<<<<
** Watch out for NG text wrap **

This code will tell you the text from whichever text box is on top. Perhaps
you can modify it to fit your needs. Post back and let me know if this will
help.

B
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
S

Steve Rindsberg

Public TextCaptured As Boolean
'------------------------------------------------

Sub GrabText(oShp As Shape)
Dim NewText As String

If TextCaptured = False Then
NewText = oShp.TextFrame.TextRange
MsgBox NewText

ActiveWindow.View.GotoSlide Index:=2

' Try this instead:
SlideShowWindows(1).View.GotoSlide (2)
' it never goes to slide 2-
' is this some kind of interaction with the mouseover event?

And since you can't select anything in slide show view, none of this will
work:
MsgBox "1" 'testing to see if the code got this far, but it never fires
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
MsgBox "2" 'never fires
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
MsgBox "3" 'never fires
ActiveWindow.Selection.TextRange.Text = NewText

' But if you name the shape something useful, like MyShape:
With SlideshowWindows(1).Presentation.Slides(2).Shapes("MyShape")
.TextFrame.TextRange.Text = NewText
End with
 
S

Steve Rindsberg

ok, now I have a newbie question ;-)

I found the tags property in VBA, but where can I set this in the main PP
environment?

You can't, unfortunately. Or you can't unless you write a little routine to
add/edit them.

We have a kind of object inspector that allows you to name shapes and
add/delete/edit tags in the 20 ameribuck Plus upgrade to the free PPTools
Starter Set (PPTools link below) if you don't want to bother writing your
own.
 
K

Keith R

it will take a little time for me to pull apart the code and understand it
all, but I was hoping to get the text from the rectangle under the mouse
position, where there are multiple sets of rectangles all on the same
sheet- so topmost in one stack of four under the pointer is what I'd want,
while ignoring any other stack of 4 on the same slide (I'm not sure from a
positioning perspective which rectangles across the sheet would be in front
of/behind anything in a different stack).

I'll also pursue the tags property option, it should be easy enough to
write a little code to let my friend edit it through a userform...

Many thanks!
Keith R
 

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