VBa中的文本到mp3

时间:2015-01-20 11:13:45

标签: excel basic

我正在用Visual Basic编写程序来朗读文本并稍后保存。但我不知道为什么发音错了

Private Sub CommandButton2_Click()
 Dim msg, sapi, FileStream, Path
 msg = "siema"
 Path = "C:\test\test.wav"
 Set FileStream = CreateObject("sapi.SpFileStream")
 Set sapi = CreateObject("sapi.spvoice")
 FileStream.Open Path, SSFMCreateForWrite, True
 Set sapi.AudioOutputStream = FileStream
 sapi.Speak "hello"  <<<<<<<<<<<<<<<<<<Error
 FileStream.Close
 Set FileStream = Nothing
 Set sapi = Nothing
End Sub 

1 个答案:

答案 0 :(得分:0)

考虑使用单元格

Sub SayHello()
    [A1] = "Hello"
    [A1].Speak
End Sub