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
------------------------------------------------------------------------------------------------------------------
Note:
To work this macro you have to enable the following Microsoft Speech Object Library.





Thanks.,
TAMATAM

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts