资源预览内容
第1页 / 共2页
第2页 / 共2页
亲,该文档总共2页全部预览完了,如果喜欢就下载吧!
资源描述
Option ExplicitDeclare Function sndPlaySound Lib “winmm.dll“ Alias “sndPlaySoundA“ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long再在 Workbook 的 BeforeSave 事件中(根据需要也可以选用其他事件)加入下列用 VBA 编 写的宏代码:With Sheet1If .Range(“A2“).Value2 Or .Range(“A2“).Value-2 Then判断 A2 单元格内的数据是否大于 2 或小于负 2x% = sndPlaySound(“C:语音语音 01.wav“, uFlags%)播放语音文件“C:语音语音 01.wav”End IfIf .Range(“B2“).Value2 Or .Range(“B2“).Value-2 Then判断 B2 单元格内的数据是否大于 2 或小于负 2x% = sndPlaySound(“C:语音语音 02.wav“, uFlags%)播放语音文件“C:语音语音 02.wav”End IfEnd WithPrivate Sub Worksheet_Change(ByVal Target As Range) 如果输入后按回车, 可以实现逐个字符朗读 Dim length As Integer Dim i As Integer Dim strT As String Dim ch As String Dim intR As Integer, intC As Integer MsgBox “你修改了数据 “ intR = ActiveCell.Row intC = ActiveCell.Column If intR 0 Then strT = Cells(intR - 1, intC) length = Len(strT) If length 0 Then For i = 1 To length ch = Mid(strT, i, 1) Application.Speech.Speak ch Next i End If End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) 如果单元 格在选定状态下按方向键,或者用鼠标改变活动单元格触发 Dim length As Integer Dim i As Integer Dim strT As String Dim ch As String Dim intR As Integer, intC As Integer intR = ActiveCell.Row intC = ActiveCell.Column If intR 0 Then strT = Cells(intR - 1, intC) length = Len(strT) If length 0 Then For i = 1 To length ch = Mid(strT, i, 1) Application.Speech.Speak ch Next i End If End If End Sub Sub 输入() Dim length As Integer Dim i As Integer Dim strT As String Dim ch As String strT = ActiveCell.Text length = Len(strT) If length 0 Then For i = 1 To length ch = Mid(strT, i, 1) Application.Speech.Speak ch Next i End If End Sub
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号