Collecting questionnaire data through action buttons

R

rel88

Hi,

I'm using powerpoint to collect questionnaire type data through action
buttons. Currently, I have multiple questions on a page and use action
buttons to allow people to select their response.

I use the following code to determine which button was pressed:
Sub question3(answerButton As Shape)
q3 = answerButton.TextFrame.TextRange.Text

End Sub

Then at the end of all the questions (24 in this part) I write the data
to a text file.

Is there a more economical way to do this or should I just continue
making a macro like the one above for each question?

Also, is there any problem with having so many of these little
scripts/macros? I'll probably have 75 by the time I'm done.

Thanks for all your help,

Ariel
 
B

Bill Dilworth

There is no problem with doing that way,but it is a bit cumbersome.

Try something along the lines of:

Option Explicit
Dim AnswerGrid(24) As String

Sub AllAnswers(oShp As Shape)
AnswerGrid(CSng(oShp.Tags("Button #"))) = _
oShp.TextFrame.TextRange.Text
End Sub

Sub AssignTag(oShp As Shape)
oShp.Tags.Add "Button #", InputBox _
("Enter the button number for this shape", _
"Add numbering tag to shape", _
oShp.Tags("Button #"))
End Sub

.......

One answer macro for all answers that are clicked.


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
R

rel88

Thanks Bill,

I'm a bit of a VB beginner (I recently got the Powerful PowerPoint for
Educators), but I think the code you gave me is a bit beyond that.

Could you possibly explain your code and how I'd implement it in my
program?

Also, my questions are across multiple slides, is that a problem?

Thanks again,

Ariel
 
S

Steve Rindsberg

Hi,

I'm using powerpoint to collect questionnaire type data through action
buttons. Currently, I have multiple questions on a page and use action
buttons to allow people to select their response.

I use the following code to determine which button was pressed:
Sub question3(answerButton As Shape)
q3 = answerButton.TextFrame.TextRange.Text

End Sub

Then at the end of all the questions (24 in this part) I write the data
to a text file.

Is there a more economical way to do this or should I just continue
making a macro like the one above for each question?

There are a couple ways around it. One would be to write the answer to the
text file as soon as the user clicks a button.

Sub question3(answerButton As Shape)
Dim iFileNum as integer
Dim sFileName as String
sFileName = "fill in the full path here"

' Open the text file, write the answer to it, close it
iFileNum = FreeFile()
Open sFileName for Append as #iFileNum
Print #iFileNum, answerButton.TextFrame.TextRange.Text
Close #iFileNum
End Sub
 
B

Bill Dilworth

Explanations in-line



Option Explicit

'By dimming the array variable outside of the sub-routines, _
you make it hold values between subs
'the AnswerGrid(...) array will hold all the answers.
Dim AnswerGrid(24) As String

Sub AllAnswers(oShp As Shape)
'oShp is set to the object that fired the sub-routine
' this would be the shape with the assigned action setting

'oShp.Tags("Button #") is a tag on the shape that identifies _
the question number
' The tags will need to be set (using the AssignTag sub) _
prior to using this sub-routine
' Tags are always text, so CSng(...) converts it to a number
' AnswerGrid(...) is your answer array
' oShp...Text is the text from the shape selected
AnswerGrid(CSng(oShp.Tags("Button #"))) = _
oShp.TextFrame.TextRange.Text

End Sub



Sub AssignTag(oShp As Shape)
'This second routine assignes the question number _
to the selected shape
'The object oShp reflects the shape selected when _
this sub fires

'oShp.Tags("Button #") is the tag on the shape that will _
hold the question number
'The InputBox is a method of asking (via a pop-up box) _
what number to assign to the tag
' This routine does not have any safegards in it, so you _
may want to add is numeric and range checking
oShp.Tags.Add "Button #", InputBox _
("Enter the button number for this shape", _
"Add numbering tag to shape", _
oShp.Tags("Button #"))
End Sub



--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
D

David M. Marcovitz

I think the answer to the original question is that this would not be a
problem, even if you go to 75 questions. However, if you look in Chapter
8 of the Powerful PowerPoint book, there is some discussion of arrays, so
you could save yourself a lot of code with that, but as long as you
understand doing it the way you outlined, you shouldn't run into any
problems.
--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/
 
A

Ariel

Thanks David,

I think I'll look through the arrays section and try to understand
what's going on. I realized I need to also check to make sure the
questions were answered on each slide before people proceed. So I can
easily put in a simple If Then statement to check for that the way I'm
currently doing it. I also have a check mark image appear to indicate
the answer was recorded. Not sure if it would be that easy with an
array?
 
D

David M. Marcovitz

I think that everything you want to do can be made easier with arrays, but
if what you are doing works for you, you can stick with that. It depends
where you want the check-mark to appear as to how easy that will be, but it
will be possible with arrays. Fire back here if you have any questions.
--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/
 

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