PowerPoint VBA

M

Marge S

Hi, I have developed some slides in PowerPoint whereby I take user input. I
store information from the user in variables such as userName, Answer1,
Answer2, etc. I am fairly new to this (Not PPT but VBA). How do I write a
Sub to save this user info I collected, when the user finished the last
question?
I tried to do something with writing to a textfile, but it never worked even
though I copied the exact script from the help module. In Perl it is so easy
to write to or append a text file.
I really appreciate any help you can give. I am trying to write some simple
projects teachers can use with students and see how easy it is to collect
info and have a very interactive PowerPoint. Thus far I can only make this
provide a summary slide that the student can print out and that is not
acceptable (too many students would accidentally shut the program down
before printing). I can make VBA do all kinds of things but not save the
variable information.
I have looked through dozens of 1000 paged text on VBA and nowhere do they
say how to store data you collect through Input boxes in PowerPoint to an
ascii text file.
Thanks for anything anyone has to offer,
Marge S.
 
D

David M. Marcovitz

Marge,

It sounds like you have gotten far with VBA, and you have probably
figured out most of what is in my book, but you might want to check it
out, or at least look at some of the examples on the web site:

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

Unfortunately, I don't have any examples that write to a file. I'll see
if I can whip something up. One thing you might do in the meantime is to
automatically print the slide that you create. In my example, you create
a slide with a print button, but immediately after creating the slide,
you could simply print, so the students don't have to do anything to
print.

--David

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

Bill Foley

I usually port mine to an Access database or send an e-mail upon completion.
You can check out my demo I have at:

http://www.pttinc.com/power_point.htm#PowerPoint

If you think you might want to send to Access, let me know, I can send you a
sample file with the database portion. I have another one that collects the
choices made with multiple choice radio buttons that pops up a message box
at the end, keeps score, etc.

Holler and I can get with you to provide some examples.
 
M

Marge S

Thanks, I ordered your book and await its arrival. It looks like it will be
fantastic for teachers to learn more.
I used to code the original BASIC back in 1979 when I was a school
psychologist and working with groups of kids who preferred to work on
computers than participate in any social-emotional events - LOL! Anyway you
can get to them! I don't remember us having any trouble saving to another
file. We used to run the programs on one floppy and save our data on the
other (before hard drives).
Yes, I did do a summary slide that could be printed but some classes don't
have printers. So I thought a teacher could actually have several users work
through a program and answer questions and before they left the module, it
would automatically capture their variables and append to a text file the
teacher could access at his or her leisure.
Again Thanks and Best wishes with the book. I've told several people about
it and sent them to Amazon. Mine should arrive any day.
Marge Sulla
 
M

Marge S

Thanks Bill, I think all I would need is how to collect the variables and
send an email.
I was trying to do an OpenTextFile command. Do you see anything wrong
with what I wrote below? TristateFalse should open the file as an ascii
file.
Thanks, Marge S.

Sub OpenEndOfDayFile()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\mytestfile.txt", ForAppending,TristateFalse)
f.Write userName
f.Close
End Sub
 
D

David M. Marcovitz

Thanks for ordering the book. Go to my web site and look at Example 7-9.
This should look somewhat familiar because you are already doing something
like this. Here is some code that you can add to this example to do what
you want:

First in the variable declarations add:

Dim answerFile

Next in the GetStarted procedure add the following after YourName:

Set fs = CreateObject("Scripting.FileSystemObject")
Set answerFile = fs.CreateTextFile(userName & "answers.txt", True)

Next in the PrintablePage procedure add the following:

answerFile.WriteLine _
"Results for " & userName
answerFile.WriteLine _
"Your Answers"
answerFile.WriteLine _
"Question 1: " & answer1
answerFile.WriteLine _
"Question 2: " & answer2
answerFile.WriteLine _
"Question 3: " & answer3
answerFile.WriteLine _
"You got " & numCorrect & " out of " & _
numCorrect + numIncorrect & "."
answerFile.Close

Note that I have created a new file that uses the student's name as part of
the filename. If a second student types the same name, it will overwrite
this file, so you might need to play with this a bit.

Also, by adding the stuff to PrintablePage, I have the printable slide and
the text file is automatically created.

This is very close to what you wanted, and it should get you started. Let
me know if you have any questions.

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

Marge S

It works like a charm. Thanks Sooooo Much.
Also just saw your note on the Append mistake. I'll check back with that as
well. I was going to store the data sequentially in a text file and then
have a "control panel" that would extract the data so the teacher could view
and perhaps send final scores and username to Excel.
I'll go through your book as soon as it arrives from Amazon and I'll be
glad to write a review for you if you would like. Thanks again, for all your
help.
Marge Sulla
 
B

Bill Foley

What e-mail program do you use? I can send sample code for Outlook or Lotus
Notes. What version of Office?
 
S

Steve Rindsberg

Hi, I have developed some slides in PowerPoint whereby I take user input. I
store information from the user in variables such as userName, Answer1,
Answer2, etc. I am fairly new to this (Not PPT but VBA). How do I write a
Sub to save this user info I collected, when the user finished the last
question?

General-purpose routine for writing a string to a text file
http://www.rdpslides.com/pptfaq/FAQ00514.htm
 
M

Marge S

Thank you. Code for Outlook would be great and appreciated. I have outlook
running in Windows XP.
This is terrific. The more ways, the merrier. Marge Sulla
 
B

Bill Foley

Here is some sample code. Keep in mind that this includes several variables
I use in my CBTs. You will need to modify accordingly. ENJOY:

=========Code starts here=======

' Remember you need to set a reference to Outlook in the VBE window.
' Click "Tools", "References", place a check next to "Microsoft Outlook X.0
Object Library" (depends on version)

Sub MailThruOutlook()

On Error GoTo Err1
Dim OL As Outlook.Application
Dim Mail As MailItem

Set OL = CreateObject("Outlook.Application")
Set Mail = OL.CreateItem(olMailItem)
Mail.Recipients.Add "put address here"
Mail.Subject = "put subject here"
Mail.Body = "I have completed the PTT, Inc. CBT presentation. I scored
" & Score * 100 & _
"% on the quiz." & Chr(10) & "First name: " & firstname & Chr(10) &
_
"Last name: " & lastname & Chr(10) & "SSN: " & SocialSecurityNumber
& Chr(10) & _
"My feedback is:" & strFeedback
Mail.Send
Set Mail = Nothing
Set OL = Nothing

MsgBox "You have successfully completed the PTT, Inc. PowerPoint CBT Demo.
Press ESC to exit this program.", vbOKOnly, "PPT Complete"
GoTo Complete
Err1:
MsgBox "An error has occurred. Please contact blah-blah-blah and report an
error", vbOKOnly, "Error Occurred"
Complete:
End Sub

========Code Ends here========
 
M

Marge S

David,
I tried what you said and that worked. Then your book came and it is truly
excellent. Then I went back to the first task and instead of letting it save
to a file for each student's (userName), I designated a file to open, use,
and append, as if all students were using the samecomputer and after each
quit, it would save their data, appending to the last data saved. It worked
quite nicely. I have to work on how to store it so I can retrieve it and use
it again or retrieve it to remember where a person left off in an e-Module.
Every computer coordinator and interested computer teacher, anyone who does
instructional presentations / training, and college level professors who are
used to using PPT, and those constructing online programs for medical CEU
programs now using such programs as Agility Presenter orAppraiso would
benefit from your book. This truly allows for actual interactive, memorable,
meaningful, and fun e-learning. Yeah, sure, I can do it with Flash, but
what teacher of other fields has time for that. Maybe the computer teacher,
but not the social studies teacher nor the medical professor teaching second
year med students interview techniques.
I have searched many a thousand paged books for dribs and drabs of VBA on
PPT. You present what teachers need if they want to create great e-learning
with a product many of them already use. You get right to the point in about
180+ pages and have more information in there than most thousand page books
that cost $60+. It leads you right to where you need to be rather than where
some author feels like telling you for several pages about some esoteric
subject that will never get you where you need to be to accomplish your
desired task. I was truly impressed and have always wished for books that
are trying to teach something to be like yours. I've already shared one of
the programs with a teacher in Australia who couldn't believe this could be
done with PPT and had never heard about VBA. I hope your book sells like
hotcakes. Thanks for the help. And Best Wishes!
Marge Sulla
 

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