Friday, 8 February 2013

How to Read a Text File with Excel VBA Macro

Excel VBA Macro To Speak Text From a File in Speech Audio Mode
Sub Speech_FromFile()

Dim Voice As SpVoice                          ' Voice Object
Dim VoiceFile As SpFileStream          ' File Stream Object
Dim File As String                                  ' File Name

Set Voice = New SpVoice
Set VoiceFile = New SpFileStream

Voice.Speak "This is an Example For Reading Out a File"

File = "C:\Documents and Settings\Administrator\My Documents\Sample.txt"

VoiceFile.Open File

Voice.SpeakStream VoiceFile

End Sub
Macro To Speak Text From Cells of Column In Excel
Sub Read_Cells()
Dim x As Integer
Dim CC As Long
CC = ActiveSheet.Rows.Count
For x = 1 To CC

If Cells(x, 1) <> "" Then
Cells(x, 1).Speak

End If
Next x
End Sub
To work this macro you have to enable the following Microsoft Speech Object Library.


No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your open Feedback only related to this Blog Posts. Please note that I cannot respond to the Anonymous Comments.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts