Exporting text in a text field

J

Johnmayo

I have created a power point presentation for a class activity where students
can enter text into a textbox when it is in Slide show mode. Is it possible
to export what they write to a txt file?

I have no VBA experience and was really chuffed when I was able to enter txt
on a slide.

Many thanks in advance
John
 
D

David M. Marcovitz

Yes, this is possible with a little VBA. It's not too difficult if you
know VBA, but without any VBA knowledge, it would be tough. I have an
example on my site that writes to a text file (under More Tricks, trick #
1), but it doesn't take the contents of a control text box:

http://www.PowerfulPowerPoint.com/

--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.PowerfulPowerPoint.com/
 
J

Johnmayo

THanks Steve and David so far.

I have played around with the code to see if I can join what both of you
have suggested (A VBA virgin here) but I dont believe that this will run

the code below is what I have extracted form both your suggestion but I need
some more help in making it work.
the file I am tryin to write to is export .txt and I have called the Text
box field reply
Thanks again in advance
John


Function TextBoxControlText(oTextBox As Shape) As String
' Pass me a text box control
' I'll return the text in the text box
' See the Test subroutine below for a usage example

' safety precaution:
If oTextBox.Type = msoOLEControlObject Then
TextBoxControlText = oTextBox.OLEFormat.Object.Text
Else
TextBoxControlText = "This isn't a text control! It's a Type " _
& CStr(oTextBox.Type) & " shape."
End If

End Function

Sub Test()
' Assumes you've selected the text box control in edit mode

MsgBox TextBoxControlText(ActiveWindow.Selection.ShapeRange(1))

End Sub

Sub exporttext()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fs, f
Dim reply As String

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("export.txt", ForAppending, TristateFalse)
Reply = InputBox("Input your answer")

f.write reply
f.Close
End Sub
 
J

Johnmayo

Your direction I think suits me best. What I am trying to do is get students
to write their reasons in a text box for selecting a particular slide (a
simple decision making class activity). I want to be able to export their
answers into a txt file that I can then use in class.

Basically what I want to achieve this:
Student enter text in text control box
this text gets sent to a textfile on the desktop
You code gets me to stage 1
Help needed for stage 2

THX
 
D

David M. Marcovitz

How's this? Create a command button and a text box on the same slide.
Double click on the command button, and insert the following code:

Private Sub CommandButton1_Click()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
'Set answerFile = fs.CreateTextFile(userName & "answers.txt", True)
Set answerFile = fs.OpenTextFile("myTestFile.txt", ForAppending, _
False)
answerFile.WriteLine (TextBox1.Text)
answerFile.Close
End Sub

Be sure that the file myTestFile.txt exists in the same place as the
PowerPoint (or include a complete path name so that it can exist in a
specific location.

--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.PowerfulPowerPoint.com/
 
J

Johnmayo

Iwill try it this evening
Thanks David

David M. Marcovitz said:
How's this? Create a command button and a text box on the same slide.
Double click on the command button, and insert the following code:

Private Sub CommandButton1_Click()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
'Set answerFile = fs.CreateTextFile(userName & "answers.txt", True)
Set answerFile = fs.OpenTextFile("myTestFile.txt", ForAppending, _
False)
answerFile.WriteLine (TextBox1.Text)
answerFile.Close
End Sub

Be sure that the file myTestFile.txt exists in the same place as the
PowerPoint (or include a complete path name so that it can exist in a
specific location.

--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.PowerfulPowerPoint.com/
 
J

Johnmayo

To David and Steven thanks for your help. It worked. I am sorrythat I have
not replied sooner. I was in car crash a few weeks back not thing serious no
serious injuries but since then let a few things slide.
thanks again
John
 
D

David M. Marcovitz

Thanks for your belated reply. It's nice to know that something I had
completely forgotten about was helpful.
--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.PowerfulPowerPoint.com/
 
Top