PDA

View Full Version : Solved: getting text from excel cells



srainbol
11-01-2008, 04:41 PM
I am using a jeopardy game in Powerpoint. I want to enter the questions & answers in excel cells and run a macro to put the cells contents into text boxes in powerpoint slides. Possible?

Oorang
11-10-2008, 02:44 PM
Totally:) But why excel/powerpoint combination (why not just use one or the other)?

srainbol
11-10-2008, 04:10 PM
I see it faster entering all questions and answers for the game in on place. So far, I have suggestions to turn the excel into a csv file w/ comma delimitation and using the SPLIT command to get an array. I've done that here:

Sub ReadAsciiFile()

Dim sFileName As String
Dim iFileNum As Integer
Dim sBuf As String
Dim strB() As String
' edit this:
sFileName = "C:\Users\srainbol\Desktop\test.txt"

' does the file exist? simpleminded test:
If Len(Dir$(sFileName)) = 0 Then
Exit Sub
End If

iFileNum = FreeFile()
Open sFileName For Input As iFileNum

Do While Not EOF(iFileNum)
Line Input #iFileNum, sBuf
strB() = Split(sBuf, ",")
' now you have the next line of the file in sBuf
' do something useful:
Debug.Print sBuf
Loop

' close the file
Close iFileNum

End Sub

Now, I need to get this into slides in the Jeopardy Game PPP

John Wilson
11-11-2008, 02:04 AM
I see it faster entering all questions and answers for the game in on place. So far, I have suggestions to turn the excel into a csv file w/ comma delimitation and using the SPLIT command to get an array. I've done that here:

Sub ReadAsciiFile()

Dim sFileName As String
Dim iFileNum As Integer
Dim sBuf As String
Dim strB() As String
' edit this:
sFileName = "C:\Users\srainbol\Desktop\test.txt"

' does the file exist? simpleminded test:
If Len(Dir$(sFileName)) = 0 Then
Exit Sub
End If

iFileNum = FreeFile()
Open sFileName For Input As iFileNum

Do While Not EOF(iFileNum)
Line Input #iFileNum, sBuf
strB() = Split(sBuf, ",")

'******NOTE should be strB=Split(sBuf,",")*********

' now you have the next line of the file in sBuf
' do something useful:
Debug.Print sBuf
Loop

' close the file
Close iFileNum

End Sub

Now, I need to get this into slides in the Jeopardy Game PPP

If eg your first line in the text file was the question,the answer,the score

Then
strB(0) would be "the question"
strB(1) = "the answer"
strB(2) ="the score"

use these values to populate the textboxes in your game slide 1 and then go on to line two for slide 2

Oorang
11-11-2008, 05:08 AM
What I was driving at was why use power point as your front end, why not do the whole thing in Excel? To build it in powerpoint you are going to have to build a harness just to hook into the events before you can even start to code the test.

srainbol
11-11-2008, 06:58 PM
for John
I do not know how to
"use these values to populate the textboxes in your game slide 1 and then go on to line two for slide 2."

Please give me an idea to work on.