0

The following code is a vb script that converts text from user input into speech. I want text to be obtained from a txt file.

Dim msg, sapi
msg=InputBox("Hello", "hello")
Set sapi =CreateObject("sapi.spvoice")
sapi.Speak msg
Ted Mad
  • 75
  • 2
  • 14
  • 1
    possible duplicate of [Read and write into a file using VBScript](http://stackoverflow.com/questions/1142678/read-and-write-into-a-file-using-vbscript) – Ken White Jul 16 '13 at 14:35

1 Answers1

5
Const ForReading = 1
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim f
Set f = fso.OpenTextFile("c:\MyTextFile.txt", ForReading)
Dim text
text = f.ReadAll
f.Close
aphoria
  • 19,796
  • 7
  • 64
  • 73