If you want to spell out the content of text file using VBA you can do it as shown below:
Sub Speech_FromFile_Example() Dim oVoice As SpVoice ' Voice Object Dim oVoiceFile As SpFileStream ' File Stream Object Dim sFile As String ' File Name Set oVoice = New SpVoice Set oVoiceFile = New SpFileStream ' -------------------------------------------------------------- ' Code for http://vbadud.blogspot.com ' -------------------------------------------------------------- oVoice.Speak "This is an example for reading out a file" sFile = "C:\ShasurData\ForBlogger\SpeechSample.txt" oVoiceFile.Open sFile oVoice.SpeakStream oVoiceFile End Sub
The above code creates a filestream and reads the text file and the Voice object speaks it out!
The code requires Microsoft Speech Object Library (see figure below)
See also: