Create File

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

Guest

I am developing a training package in powerpoint. I intend to have users enter their name and answer questions in the presentation. I would like to record the users name and how they answered the questions. I can use command buttons and inputbox's and store various things as variables while the user progresses through the presentation. What I am having trouble with is creating the file. I have included some code of how i created a file (text file) in excel. For some reason it does not work in Powerpoint. Can some one assit me please.

Dim myCriteria As String
Dim myOutText As String
Dim tmpfileName As String
SavDir = Application.GetTempName(FileNameIB, "Text Files (*.txt), *.txt")
If SavDir = False Then
NoSave = MsgBox("No text file has been created!", vbCritical, "Cancelled")
End
Else
tmpfileName = SavDir
'Open tmpfileName For Output As #1 - to clear and start fresh
Open tmpfileName For Append Access Write As #1
myOutText = "FileName: " & FileNameIB _
& vbNewLine & "Name: " & NameIB _
& vbNewLine & "Date: " & Date
Write #1, myOutText
Close #1
Finish = MsgBox("The following text file has been created, " & SavDir & ".", vbInformation, "Complete")
End If
 
I am developing a training package in powerpoint. I intend to have users enter
their name and answer questions in the presentation. I would like to record the users
name and how they answered the questions. I can use command buttons and inputbox's
and store various things as variables while the user progresses through the
presentation. What I am having trouble with is creating the file. I have included
some code of how i created a file (text file) in excel. For some reason it does not
work in Powerpoint. Can some one assit me please.

Thanks for posting the code ... that helps.
It's also useful to know where it fails and what the error message is, but for
starters:
Dim myCriteria As String
Dim myOutText As String
Dim tmpfileName As String

Fails here because there's no .GetTempName method in PowerPoint
A function you've written yourself?
SavDir = Application.GetTempName(FileNameIB, "Text Files (*.txt), *.txt")
If SavDir = False Then
NoSave = MsgBox("No text file has been created!", vbCritical, "Cancelled")
End
Else

Also, SavDir, FileNameIB, NameIB, Date are undeclared here.
Are they declared elsewhere (I assume they are, and hold the values from the controls
you want to save?)

SavDir is treated as a Boolean above, a string below ... sometimes you can get away
with this stuff, sometimes VB will bite you for it. Might be better to declare and
use your variables as explicit types.
 
Back
Top