VBA Get textbox value

  • Thread starter Thread starter sanj
  • Start date Start date
S

sanj

Hi,

Is this possible:

Slide one has 30 textboxes, I would like to create an array

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

when the user selects a textbox I would like to above macro to get the value
of the textbox and open the corresponding file - is this possible?

Thanks,

Sanj
 
Are these Active X text boxes created with the control toolbox, or are
they standard textboxes created with the drawing tools? If it is the
latter, you can tell which text box was clicked by assigning a parameter
to the macro that all the textboxes run. Example 8.10 on my site
demonstrates this:

http://www.loyola.edu/education/PowerfulPowerPoint/

Click on "Examples by Chapter" and "Chapter 8" to find the example.

--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.loyola.edu/education/PowerfulPowerPoint/
 
David,

I've checked your examples, its almost what I am looking for except I would
like to get the value/contents of the selected (clicked) textbox then use
the array to open a document:

if value/contents of selected textbox is val10 open a.xls

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

Regards,

Sanj



David M. Marcovitz said:
Are these Active X text boxes created with the control toolbox, or are
they standard textboxes created with the drawing tools? If it is the
latter, you can tell which text box was clicked by assigning a parameter
to the macro that all the textboxes run. Example 8.10 on my site
demonstrates this:

http://www.loyola.edu/education/PowerfulPowerPoint/

Click on "Examples by Chapter" and "Chapter 8" to find the example.

--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.loyola.edu/education/PowerfulPowerPoint/

Hi,

Is this possible:

Slide one has 30 textboxes, I would like to create an array

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

when the user selects a textbox I would like to above macro to get the
value of the textbox and open the corresponding file - is this
possible?

Thanks,

Sanj
 
Sorry David,

I looked at your other example, Example08-10 this is much closer to what I
need, is it possible to use an array or do I need to use the IF/ELSE
statement?

Regards,

Sanj


sanj said:
David,

I've checked your examples, its almost what I am looking for except I would
like to get the value/contents of the selected (clicked) textbox then use
the array to open a document:

if value/contents of selected textbox is val10 open a.xls

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

Regards,

Sanj



David M. Marcovitz said:
Are these Active X text boxes created with the control toolbox, or are
they standard textboxes created with the drawing tools? If it is the
latter, you can tell which text box was clicked by assigning a parameter
to the macro that all the textboxes run. Example 8.10 on my site
demonstrates this:

http://www.loyola.edu/education/PowerfulPowerPoint/

Click on "Examples by Chapter" and "Chapter 8" to find the example.

--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.loyola.edu/education/PowerfulPowerPoint/

Hi,

Is this possible:

Slide one has 30 textboxes, I would like to create an array

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

when the user selects a textbox I would like to above macro to get the
value of the textbox and open the corresponding file - is this
possible?

Thanks,

Sanj
 
Instead of IF/ELSE try using "Select Case" Much simpler to write and will
execute MUCH faster.

Austin Myers
MS PowerPoint MVP Team

PowerPoint Video and PowerPoint Sound Solutions www.pfcmedia.com



sanj said:
Sorry David,

I looked at your other example, Example08-10 this is much closer to what I
need, is it possible to use an array or do I need to use the IF/ELSE
statement?

Regards,

Sanj


sanj said:
David,

I've checked your examples, its almost what I am looking for except I would
like to get the value/contents of the selected (clicked) textbox then use
the array to open a document:

if value/contents of selected textbox is val10 open a.xls

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

Regards,

Sanj



David M. Marcovitz said:
Are these Active X text boxes created with the control toolbox, or are
they standard textboxes created with the drawing tools? If it is the
latter, you can tell which text box was clicked by assigning a parameter
to the macro that all the textboxes run. Example 8.10 on my site
demonstrates this:

http://www.loyola.edu/education/PowerfulPowerPoint/

Click on "Examples by Chapter" and "Chapter 8" to find the example.

--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.loyola.edu/education/PowerfulPowerPoint/


Hi,

Is this possible:

Slide one has 30 textboxes, I would like to create an array

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

when the user selects a textbox I would like to above macro to get the
value of the textbox and open the corresponding file - is this
possible?

Thanks,

Sanj
 
Yes, for 30 different options, a Select Case is probably better. There's
probably a data structure that can do what you want more cleanly, but I
don't know how to do it in VBA. What is the appeal of the array? You
would have to load the array and then access the contents of the array.
The Select Case (or the If/Else) would probably be about the same amount
of code.
--David

Instead of IF/ELSE try using "Select Case" Much simpler to write and
will execute MUCH faster.

Austin Myers
MS PowerPoint MVP Team

PowerPoint Video and PowerPoint Sound Solutions www.pfcmedia.com



sanj said:
Sorry David,

I looked at your other example, Example08-10 this is much closer to
what I need, is it possible to use an array or do I need to use the
IF/ELSE statement?

Regards,

Sanj


sanj said:
David,

I've checked your examples, its almost what I am looking for except
I would
like to get the value/contents of the selected (clicked) textbox
then use
the array to open a document:

if value/contents of selected textbox is val10 open a.xls

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

Regards,

Sanj



Are these Active X text boxes created with the control toolbox,
or are they standard textboxes created with the drawing tools? If
it is the latter, you can tell which text box was clicked by
assigning a parameter
to the macro that all the textboxes run. Example 8.10 on my site
demonstrates this:

http://www.loyola.edu/education/PowerfulPowerPoint/

Click on "Examples by Chapter" and "Chapter 8" to find the
example.

--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.loyola.edu/education/PowerfulPowerPoint/


Hi,

Is this possible:

Slide one has 30 textboxes, I would like to create an array

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

when the user selects a textbox I would like to above macro to
get the
value of the textbox and open the corresponding file - is this
possible?

Thanks,

Sanj
 
David,

I've checked your examples, its almost what I am looking for except I would
like to get the value/contents of the selected (clicked) textbox then use
the array to open a document:

if value/contents of selected textbox is val10 open a.xls

You can apply tags to the text boxes instead. Makes the whole thing more
maintainable. A tag is a named string.

So for example, select a text box as above and to tag it:

With ActiveWindow.Selection.ShapeRange(1)
Call .Tags.Add("Document","a.xls")
End With

Repeat for all your text boxes.

Assign the same macro to each text box, let's call it ShapeClick

Sub ShapeClick(oSh as Shape)
If oSh.Tags("Document") <> "" Then
' It has a document tag, the tag gives the name of the doc
' to launch
' so do whatever you need to with:
MsgBox oSh.Tags("Document")
End If
End Sub

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

Regards,

Sanj

David M. Marcovitz said:
Are these Active X text boxes created with the control toolbox, or are
they standard textboxes created with the drawing tools? If it is the
latter, you can tell which text box was clicked by assigning a parameter
to the macro that all the textboxes run. Example 8.10 on my site
demonstrates this:

http://www.loyola.edu/education/PowerfulPowerPoint/

Click on "Examples by Chapter" and "Chapter 8" to find the example.

--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.loyola.edu/education/PowerfulPowerPoint/

Hi,

Is this possible:

Slide one has 30 textboxes, I would like to create an array

myArr = [
val10, a.xls
val11, b.xls
val12, c.doc
val13, d.pdf
]

when the user selects a textbox I would like to above macro to get the
value of the textbox and open the corresponding file - is this
possible?

Thanks,

Sanj
 

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

Back
Top