Generate Random Words In PowerPoint From Text File

The Tech Train
The Tech Train
13.6 هزار بار بازدید - 8 سال پیش - In this tutorial I'm going
In this tutorial I'm going to share with you a handy resource which I use in some of my lessons in schools to help students learn specific topics, make connections between topics and become more fluent and confident in talking about keywords and terms. The PowerPoint presentation I use imports a text file of keywords, and then randomly chooses two words from the list and displays them on the slide. A button allows the user to continue to generate randomly selected pairs of words from the text file.

To switch topics or subjects all you need to do is to swap the text file for a different one - the PowerPoint presentation will simply import the new list for you. It's a few lines of VBA, and hopefully it should make some sense. I walk you right through the whole process from start to finish, and I've also included the code I used below.

If you have any questions or comments please do leave me a comment.

VBA Code
=======

Public myArray, Word1, Word2

Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)

If SSW.Presentation.SlideShowSettings.StartingSlide Then
Randomize
Label1.Caption = ""
Label2.Caption = ""

Dim path
path = ActivePresentation.path & "\words.txt"

Open path For Input As #1
filecontent = Input(LOF(1), #1)
Close #1

myArray = Split(filecontent, vbCrLf)

End If

End Sub

Private Sub CommandButton1_Click()


Word1 = Int((UBound(myArray)) * Rnd)
Word2 = Int((UBound(myArray)) * Rnd)

Do While Word1 = Word2
   Word2 = Int((UBound(myArray)) * Rnd)
Loop

Label1.Caption = myArray(Word1)
Label2.Caption = myArray(Word2)

End Sub
8 سال پیش در تاریخ 1395/02/09 منتشر شده است.
13,646 بـار بازدید شده
... بیشتر