word VBA 编译错误 缺少:语句结束

2025-03-07 01:11:59
推荐回答(2个)
回答1:

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

回答2:

Range("A1").Formula = "=if(sheet1!b2=""期中"",""八年级期中考试成绩"",""八年级期期末考试成绩"")"