Easy way to hide/link slide-specific text without much VBA?

  • Thread starter Thread starter KR
  • Start date Start date
K

KR

I am creating a series of "test" slides with objects (boxes) linked to code.
Multiple Choice, True/False, Matching, etc.

What I'd like to do is be able to add any shape I want during development,
and set a property or variable in PowerPoint (not in VBE) that I can use
when the shape is clicked, to create a message box. For example, I show a
picture of a red apple, and ask the question "Is the apple red or green",
then have two shapes, one that says "red" and the other says "green". If the
user clicks on the shape that says "red" I want a message box that says:
[msgbox "The apple is red",,"Correct Answer"]

So if I were able to set the following properties in Powerpoint:

Shape1.hiddenproperty1 = "The apple is red"
Shape1.hiddenproperty2 = "Correct Answer"
and
Shape2.hiddenproperty1 = "The apple is not green"
Shape2.hiddenproperty2 = "Incorrect Answer"

then code something like:
Sub Identify(oShp As Shape)
msgbox (oShp.hiddenproperty1,,hiddenproperty2)
End Sub

then I could do all my development in Powerpoint, and not have to create a
sub (or separate msgbox statement) for every object I add...

Is there a way to do this? I can't find any way to access a shape's
properties (hidden or otherwise) other than the basic ones exposed through
the Powerpoint interface...

Many thanks,
Keith
 
What about the AlternativeText property? You can access this in the
Format AutoShape dialog box under the Web tab when you are in PowerPoint,
and you can access this with Shape1.AlternativeText. You could easily
manipulate this text to include two lines or some other special character
to separate the two parts so you can write a VBA procedure to display the
first line sometimes and the second line at other times.

An alternative is to put your text right in the object in a color that is
the same as the background so it can't be seen.

--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
Alternative text seems to work- since I needed multiple fields, I used "::"
in the string to separate the two fields I needed, and ended up with the
following code- Thanks!! I will need to test it out on the internet, as this
actually will be accessed from our departmental server, and I need to make
sure there isn't lag, otherwise the user might see the correct answer each
time before having to respond ;-)

Sub MakeMessage(oShp As Shape)
MTitle = Left(oShp.AlternativeText, InStr(1, oShp.AlternativeText,
"::") - 1)
MContent = Right(oShp.AlternativeText, Len(MTitle) + 3)
MsgBox MContent, , MTitle
End Sub

David M. Marcovitz said:
What about the AlternativeText property? You can access this in the
Format AutoShape dialog box under the Web tab when you are in PowerPoint,
and you can access this with Shape1.AlternativeText. You could easily
manipulate this text to include two lines or some other special character
to separate the two parts so you can write a VBA procedure to display the
first line sometimes and the second line at other times.

An alternative is to put your text right in the object in a color that is
the same as the background so it can't be seen.

--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/

I am creating a series of "test" slides with objects (boxes) linked to
code. Multiple Choice, True/False, Matching, etc.

What I'd like to do is be able to add any shape I want during
development, and set a property or variable in PowerPoint (not in VBE)
that I can use when the shape is clicked, to create a message box. For
example, I show a picture of a red apple, and ask the question "Is the
apple red or green", then have two shapes, one that says "red" and the
other says "green". If the user clicks on the shape that says "red" I
want a message box that says: [msgbox "The apple is red",,"Correct
Answer"]

So if I were able to set the following properties in Powerpoint:

Shape1.hiddenproperty1 = "The apple is red"
Shape1.hiddenproperty2 = "Correct Answer"
and
Shape2.hiddenproperty1 = "The apple is not green"
Shape2.hiddenproperty2 = "Incorrect Answer"

then code something like:
Sub Identify(oShp As Shape)
msgbox (oShp.hiddenproperty1,,hiddenproperty2)
End Sub

then I could do all my development in Powerpoint, and not have to
create a sub (or separate msgbox statement) for every object I add...

Is there a way to do this? I can't find any way to access a shape's
properties (hidden or otherwise) other than the basic ones exposed
through the Powerpoint interface...

Many thanks,
Keith
 
I am creating a series of "test" slides with objects (boxes) linked to code.
Multiple Choice, True/False, Matching, etc.

What I'd like to do is be able to add any shape I want during development,
and set a property or variable in PowerPoint (not in VBE) that I can use
when the shape is clicked, to create a message box. For example, I show a
picture of a red apple, and ask the question "Is the apple red or green",
then have two shapes, one that says "red" and the other says "green". If the
user clicks on the shape that says "red" I want a message box that says:
[msgbox "The apple is red",,"Correct Answer"]

So if I were able to set the following properties in Powerpoint:

Shape1.hiddenproperty1 = "The apple is red"
Shape1.hiddenproperty2 = "Correct Answer"
and
Shape2.hiddenproperty1 = "The apple is not green"
Shape2.hiddenproperty2 = "Incorrect Answer"

then code something like:
Sub Identify(oShp As Shape)
msgbox (oShp.hiddenproperty1,,hiddenproperty2)
End Sub

then I could do all my development in Powerpoint, and not have to create a
sub (or separate msgbox statement) for every object I add...

Is there a way to do this? I can't find any way to access a shape's
properties (hidden or otherwise) other than the basic ones exposed through
the Powerpoint interface...

Any shape (or slide or presentation) can have as many tags (each of which is a
text string) as a reasonable person might want.

Call Shape2.Tags.Add("Question", "Is the apple green?")

and so on.

Then set each shape to run a macro (the same one):

Sub ClickedMe(oShp as Shape)
msgbox oShp.Tags("Question")
End Sub

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Apologies for the delayed response.
Just back from PowerPoint Live 2004
Had a great time, learned a lot
================================================
 
Back
Top