Sub SpeakText() On Error Resume Next Set speech = New SpVoice Selection.MoveLeft Unit:=wdWord, Count:=1 Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend If Len(Selection.Text) > 1 Then speech.Speak Trim(Selection.Text), SVSFlagsAsync + SVSFPurgeBeforeSpeak End If Selection.MoveRight Unit:=wdWord, Count:=1 Do DoEvents Loop Until speech.WaitUntilDone(10) Set speech = Nothing End Sub
這個在word 中的宏設定部分提示 編譯錯誤 缺少:陳述句結束。
請各位大神幫忙解決,謝謝,謝謝。
uj5u.com熱心網友回復:
第1. 代碼陳述句要“換行結束”,或用西文冒號分隔每句代碼。第2. 你這段宏代碼,需要參考一個什么什么的語音庫,才能運行。
Sub SpeakText()
On Error Resume Next
Set speech = New SpVoice
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
If Len(Selection.Text) > 1 Then
speech.Speak Trim(Selection.Text), SVSFlagsAsync + SVSFPurgeBeforeSpeak
End If
Selection.MoveRight Unit:=wdWord, Count:=1
Do
DoEvents
Loop Until speech.WaitUntilDone(10)
Set speech = Nothing
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/72128.html
標籤:VBA
下一篇:Inet POST提交的問題
