How to stop speak macro

A

A

This great macro:
Sub ReadToMe()
Set objRange = Selection.Range
strText = objRange.Text
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Speak strText
End Sub

From Steve Yandl

Speaks the selected text
However, I cannot stop it once it starts.
How does one kill a macro

WORD 2003

Al
 
J

Jean-Guy Marcil

A was telling us:
A nous racontait que :
This great macro:
Sub ReadToMe()
Set objRange = Selection.Range
strText = objRange.Text
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Speak strText
End Sub

From Steve Yandl

Speaks the selected text
However, I cannot stop it once it starts.
How does one kill a macro

What do you mean by "I cannot stop it once it starts"?
Does it repeat the text ad infinitum?

Just in case, have you tried:

Sub ReadToMe()

Dim objRange As Range
Dim strText As String
Dim objVoice As Object

Set objRange = Selection.Range
strText = objRange.Text
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Speak strText

Set objVoice = Nothing

End Sub





--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

Steve Yandl

The object created does have a 'pause' method and a 'restore' method.
However, the few times I've used it, I simply supplied it with small enough
text strings that I didn't see the need to stop it (you could break down a
large selection into a collection of sentences perhaps).

By the way, you should add the line suggested by Jean-Guy Marcil to set the
object to nothing at the end of the subroutine. I don't think it will solve
your problem but I should have included it when I initially provided you the
sample subroutine.

Steve Yandl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top