I have found this code to fetch random words from txt file. Both Powerpoint and txt file are in the same folder. I am getting run-time error 13 whenever I run it. Can someone help please
The original code had 2 words, but I only needed one so edited, but I get same error.
I got this from youtube and others have commented the same error but I am not able to resolve.
Public myArray, Word1
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.Presentation.SlideShowSettings.StartingSlide Then
Randomize
Label1.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)
Label1.Caption = myArray(Word1)
End Sub
The original code had 2 words, but I only needed one so edited, but I get same error.
I got this from youtube and others have commented the same error but I am not able to resolve.
Public myArray, Word1
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.Presentation.SlideShowSettings.StartingSlide Then
Randomize
Label1.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)
Label1.Caption = myArray(Word1)
End Sub