Exporting text in a text field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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/
 
David M. said:
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:

OK. You pulled us most of the way there. I'll give it the last push:

Show me the text in an OLE text control on a slide
http://www.rdpslides.com/pptfaq/FAQ00772.htm
 
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
 
Johnmayo said:
THanks Steve and David so far.

No problem.

Let's back up a bit. The code I posted lets you get the text from a text
control on a slide. David's lets you ask the user for text and writes it to
file.

Which direction suits your project better? We'll go from there.
 
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
 
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/
 
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/
 
Hi John,

In your reply to David, you said you were going to give his suggestion a shot that
evening. I was waiting to hear back to see how that worked out.

If you wanted more info first, let me know ...
 
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
 
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/
 
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

What David said. And I'm glad to hear that you're ok. Take care of yourself!
 

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