473,416 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Can I use VBA to send text to Microsoft Sam (Win XP) from Access 97 to 'speak' the code in modules?

MLH
From time to time, I find myself cross checking one block of code
against another. Usually older stuff in which I've made modifications
that don't work. I don't remember what all the changes were so I
have to print an earlier version and compare it against a printout
of a more recent version. I am dyslexic and it is helpful to have
someone read one copy while I follow along on another copy
until we hit a discrepancy.

Could I somehow call on Microsoft Sam to do that w/o involving
another person? I have that program in my Control Panel. I don't
know how to call it up and feed it text though.

Any exeriences you care to share?
Nov 21 '05 #1
17 4787
MLH
I tried following what I found at
http://msdn.microsoft.com/library/de...tml/sa03f1.asp
but I just couldn't seem to get it to work.
Nov 21 '05 #2
MLH wrote:
From time to time, I find myself cross checking one block of code
against another. Usually older stuff in which I've made modifications
that don't work. I don't remember what all the changes were so I
have to print an earlier version and compare it against a printout
of a more recent version. I am dyslexic and it is helpful to have
someone read one copy while I follow along on another copy
until we hit a discrepancy.

Could I somehow call on Microsoft Sam to do that w/o involving
another person? I have that program in my Control Panel. I don't
know how to call it up and feed it text though.

Any exeriences you care to share?


I have an old DOS (1986) utility from Norton, NE.COM, that has been a
godsend for me over the years. I can pull up 2 files and press a key
and it will go to the first difference between the two files. I can go
thru both files and see all discrepencies between the two files. Since
it's DOS, you can't cut/paste the changes into a program like NotePad.

Anyway, go to http://www.tucows.com. In search, enter something like
Text Compare. You'll find some programs there that should do what you want.
Nov 21 '05 #3
MLH wrote:
From time to time, I find myself cross checking one block of code
against another. Usually older stuff in which I've made modifications
that don't work. I don't remember what all the changes were so I
have to print an earlier version and compare it against a printout
of a more recent version. I am dyslexic and it is helpful to have
someone read one copy while I follow along on another copy
until we hit a discrepancy.

Could I somehow call on Microsoft Sam to do that w/o involving
another person? I have that program in my Control Panel. I don't
know how to call it up and feed it text though.

Any exeriences you care to share?


There is some unix software ported to windows at:

http://unxutils.sourceforge.net/

See if the diff.exe program does what you need. BTW, there was a
poster in the MS groups within the last several weeks who had a problem
that diff.exe could help solve. An enterprising consultant could
benefit from such knowledge.

James A. Fortune

Sometimes I save a whole module into emacs, run a powerful macro or
two, then paste the code back into Access.

Nov 21 '05 #4
MLH
On Mon, 21 Nov 2005 12:59:31 -0500, MLH <CR**@NorthState.net> wrote:
I tried following what I found at
http://msdn.microsoft.com/library/de...tml/sa03f1.asp
but I just couldn't seem to get it to work.


Forgot to say what the error was: Runtime error #2683: There is no
object in this control The offending line is...

Set tts = Me.ActiveXCtl0.Object
Nov 21 '05 #5
MLH
Thx for the suggestion. I would be happy if the reader Microsoft
Sam would work. Meanwhile, diff.exe you say? Thx for the tip on
consulting. I sometime consult with myself - but not with anyone
else. Often, when I am consulting with myself, I often suggest to
myself that I call someone else and ask them.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

There is some unix software ported to windows at:

http://unxutils.sourceforge.net/

See if the diff.exe program does what you need. BTW, there was a
poster in the MS groups within the last several weeks who had a problem
that diff.exe could help solve. An enterprising consultant could
benefit from such knowledge.

James A. Fortune

Sometimes I save a whole module into emacs, run a powerful macro or
two, then paste the code back into Access.


Nov 21 '05 #6

"Salad" <oi*@vinegar.com> schreef in bericht news:de****************@newsread3.news.pas.earthli nk.net...
I have an old DOS (1986) utility from Norton, NE.COM, that has been a
godsend for me over the years. I can pull up 2 files and press a key
and it will go to the first difference between the two files. I can go
thru both files and see all discrepencies between the two files. Since
it's DOS, you can't cut/paste the changes into a program like NotePad.


I use Windows Commander to do just that.
That program is just *fantastic*. You will never use Explorer again ...
File <> Compare by content is what you need here.

Arno R
Nov 21 '05 #7
Can't you just cut and paste into notepad...and have sam read that???

You have to select the text anyway....
Just keep a notepad document open all day....

Highlight...flip to notepad....ctrl-a (select all), then ctrl-v paste you
text...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 21 '05 #8

"Arno R" <ar***********@tiscali.nl> wrote in message
news:43********************@dreader2.news.tiscali. nl...

"Salad" <oi*@vinegar.com> schreef in bericht
news:de****************@newsread3.news.pas.earthli nk.net...
I have an old DOS (1986) utility from Norton, NE.COM, that has been a
godsend for me over the years. I can pull up 2 files and press a key
and it will go to the first difference between the two files. I can go
thru both files and see all discrepencies between the two files. Since
it's DOS, you can't cut/paste the changes into a program like NotePad.


I use Windows Commander to do just that.
That program is just *fantastic*. You will never use Explorer again ...
File <> Compare by content is what you need here.

Arno R

Windows Commander (now renamed Total Commander) is a really slick program.
I'm too cheap, however, to shell out the few bucks for it. I use a freeware
program called ExamDiff. Excellent tool.

Randy

Nov 21 '05 #9
On Mon, 21 Nov 2005 12:44:53 -0500, MLH <CR**@NorthState.net> wrote:
From time to time, I find myself cross checking one block of code
against another. Usually older stuff in which I've made modifications
that don't work. I don't remember what all the changes were so I
have to print an earlier version and compare it against a printout
of a more recent version. I am dyslexic and it is helpful to have
someone read one copy while I follow along on another copy
until we hit a discrepancy.

Could I somehow call on Microsoft Sam to do that w/o involving
another person? I have that program in my Control Panel. I don't
know how to call it up and feed it text though.

Any exeriences you care to share?


Yes.
Example code ex MS below.

I did this some time ago when you had to download SAPI and install it but the voice feature is
now in Windows (2000/XP) so maybe that is no longer necessary.
Option Compare Database
Option Explicit

'================================================= ============================
'
' This SimpleTTS sample application demonstrates how to create a SpVoice object
' and how to use it to speak text and save it to a .wav file.
'
' Copyright @ 2001 Microsoft Corporation All Rights Reserved.
'================================================= ============================

'Declare the SpVoice object.
Dim Voice As SpVoice
'Note - Applications that require handling of SAPI events should declair the
'SpVoice as follows:
'Dim WithEvents Voice As SpVoice

Public Sub InitialiseVoice()
' Initialize the voice object
Set Voice = New SpVoice
End Sub

Public Sub SpeakIt(Txt$, ByVal sMode&, Wfilename$)
'On Error GoTo Speak_Error

'mode=1 speak
'mode=2 save

If Len(Txt) = 0 Then Return
If sMode = 2 Then
SaveToWav Txt$, Wfilename
Else
' Call the Speak method with the text from the text box. We use the
' SVSFlagsAsync flag to speak asynchronously and return immediately
' from this call.
Voice.Speak Txt, SVSFlagsAsync
End If
Exit Sub

Speak_Error:
MsgBox "Speak Error!", vbOKOnly
End Sub

Private Sub SaveToWav(Txt$, Wfilename$)
' Create a wave stream
Dim cpFileStream As New SpFileStream

If Len(Wfilename) = 0 Then Return

' Set audio format
cpFileStream.Format.Type = SAFT22kHz16BitMono
' Create a new .wav file for writing. False indicates that we're not
' interested in writing events into the .wav file.
' Note - this line of code will fail if the file exists and is currently open.
cpFileStream.Open Wfilename, SSFMCreateForWrite, False

' Set the .wav file stream as the output for the Voice object
Set Voice.AudioOutputStream = cpFileStream

' Calling the Speak method now will send the output to the "SimpTTS.wav" file.
' We use the SVSFDefault flag so this call does not return until the file is
' completely written.
Voice.Speak Txt, SVSFDefault

' Close the file
cpFileStream.close
Set cpFileStream = Nothing

' Reset the Voice object's output to 'Nothing'. This will force it to use
' the default audio output the next time.
Set Voice.AudioOutputStream = Nothing

Cancel:
Exit Sub
End Sub

Nov 23 '05 #10
MLH
You know, you're probably quite right. I just don't know how to do
that. The only way I've ever heard SAM talk is when I open him up
and type in a line manually into the one-line textbox there for
testing.
On Mon, 21 Nov 2005 22:42:38 GMT, "Albert D. Kallal" <ka****@msn.com>
wrote:
Can't you just cut and paste into notepad...and have sam read that???

You have to select the text anyway....
Just keep a notepad document open all day....

Highlight...flip to notepad....ctrl-a (select all), then ctrl-v paste you
text...


Nov 23 '05 #11
MLH
Thx polite person. I'm going to have a go at it.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Example code ex MS below.

I did this some time ago when you had to download SAPI and install it but the voice feature is
now in Windows (2000/XP) so maybe that is no longer necessary.
Option Compare Database
Option Explicit

'================================================ =============================
'
' This SimpleTTS sample application demonstrates how to create a SpVoice object
' and how to use it to speak text and save it to a .wav file.
'
' Copyright @ 2001 Microsoft Corporation All Rights Reserved.
'================================================ =============================

'Declare the SpVoice object.
Dim Voice As SpVoice
'Note - Applications that require handling of SAPI events should declair the
'SpVoice as follows:
'Dim WithEvents Voice As SpVoice

Public Sub InitialiseVoice()
' Initialize the voice object
Set Voice = New SpVoice
End Sub

Public Sub SpeakIt(Txt$, ByVal sMode&, Wfilename$)
'On Error GoTo Speak_Error

'mode=1 speak
'mode=2 save

If Len(Txt) = 0 Then Return
If sMode = 2 Then
SaveToWav Txt$, Wfilename
Else
' Call the Speak method with the text from the text box. We use the
' SVSFlagsAsync flag to speak asynchronously and return immediately
' from this call.
Voice.Speak Txt, SVSFlagsAsync
End If
Exit Sub

Speak_Error:
MsgBox "Speak Error!", vbOKOnly
End Sub

Private Sub SaveToWav(Txt$, Wfilename$)
' Create a wave stream
Dim cpFileStream As New SpFileStream

If Len(Wfilename) = 0 Then Return

' Set audio format
cpFileStream.Format.Type = SAFT22kHz16BitMono
' Create a new .wav file for writing. False indicates that we're not
' interested in writing events into the .wav file.
' Note - this line of code will fail if the file exists and is currently open.
cpFileStream.Open Wfilename, SSFMCreateForWrite, False

' Set the .wav file stream as the output for the Voice object
Set Voice.AudioOutputStream = cpFileStream

' Calling the Speak method now will send the output to the "SimpTTS.wav" file.
' We use the SVSFDefault flag so this call does not return until the file is
' completely written.
Voice.Speak Txt, SVSFDefault

' Close the file
cpFileStream.close
Set cpFileStream = Nothing

' Reset the Voice object's output to 'Nothing'. This will force it to use
' the default audio output the next time.
Set Voice.AudioOutputStream = Nothing

Cancel:
Exit Sub
End Sub


Nov 23 '05 #12
MLH
I get an error at compile time on the following line
Dim Voice As SpVoice
telling me user-defined type not defined.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx

Yes.
Example code ex MS below.

I did this some time ago when you had to download SAPI and install it but the voice feature is
now in Windows (2000/XP) so maybe that is no longer necessary.
Option Compare Database
Option Explicit

'================================================ =============================
'
' This SimpleTTS sample application demonstrates how to create a SpVoice object
' and how to use it to speak text and save it to a .wav file.
'
' Copyright @ 2001 Microsoft Corporation All Rights Reserved.
'================================================ =============================

'Declare the SpVoice object.
Dim Voice As SpVoice
'Note - Applications that require handling of SAPI events should declair the
'SpVoice as follows:
'Dim WithEvents Voice As SpVoice

Public Sub InitialiseVoice()
' Initialize the voice object
Set Voice = New SpVoice
End Sub

Public Sub SpeakIt(Txt$, ByVal sMode&, Wfilename$)
'On Error GoTo Speak_Error

'mode=1 speak
'mode=2 save

If Len(Txt) = 0 Then Return
If sMode = 2 Then
SaveToWav Txt$, Wfilename
Else
' Call the Speak method with the text from the text box. We use the
' SVSFlagsAsync flag to speak asynchronously and return immediately
' from this call.
Voice.Speak Txt, SVSFlagsAsync
End If
Exit Sub

Speak_Error:
MsgBox "Speak Error!", vbOKOnly
End Sub

Private Sub SaveToWav(Txt$, Wfilename$)
' Create a wave stream
Dim cpFileStream As New SpFileStream

If Len(Wfilename) = 0 Then Return

' Set audio format
cpFileStream.Format.Type = SAFT22kHz16BitMono
' Create a new .wav file for writing. False indicates that we're not
' interested in writing events into the .wav file.
' Note - this line of code will fail if the file exists and is currently open.
cpFileStream.Open Wfilename, SSFMCreateForWrite, False

' Set the .wav file stream as the output for the Voice object
Set Voice.AudioOutputStream = cpFileStream

' Calling the Speak method now will send the output to the "SimpTTS.wav" file.
' We use the SVSFDefault flag so this call does not return until the file is
' completely written.
Voice.Speak Txt, SVSFDefault

' Close the file
cpFileStream.close
Set cpFileStream = Nothing

' Reset the Voice object's output to 'Nothing'. This will force it to use
' the default audio output the next time.
Set Voice.AudioOutputStream = Nothing

Cancel:
Exit Sub
End Sub


Nov 23 '05 #13
On Tue, 22 Nov 2005 10:46:11 -0500, MLH <CR**@NorthState.net> wrote:
I get an error at compile time on the following line
Dim Voice As SpVoice
telling me user-defined type not defined.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx


I see that I have a reference to the Microsoft Speech Object Library.
Open a code module, go to Tools/ References and see if you can find it in the list, and check it.
If not try to browse to sapi.dll.

Nov 23 '05 #14
On Tue, 22 Nov 2005 16:03:54 GMT, polite person <si*****@ease.com> wrote:
On Tue, 22 Nov 2005 10:46:11 -0500, MLH <CR**@NorthState.net> wrote:
I get an error at compile time on the following line
Dim Voice As SpVoice
telling me user-defined type not defined.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx


I see that I have a reference to the Microsoft Speech Object Library.
Open a code module, go to Tools/ References and see if you can find it in the list, and check it.
If not try to browse to sapi.dll.


If that fails you can always download the speech sdk, which I did in NT4 days -
http://www.microsoft.com/speech/download/sdk51/

it is big and contains a lot more than you need. I can't help feeling that because the speech is
already in XP you shouldn't need to have to download anything.

You probably know that you can set the speaking voice properties via the control panel, speech. You
can also set these by program but if you change them this a a global setting, not just for your
program.

Nov 23 '05 #15
MLH
After adding the Reference you mentioned, I clicked Debug, Compile
Loaded Modules and received an error saying "There was an error
loading an ActiveX control on one of your forms or reports. Make sure
all the controls you are using are properly registered. For info...."

The second time I did the same thing - the error did NOT reappear.
Same for each successive time. I'm curious about the initial error
report. But I can live with dismissing it as a subspace anomoly.

Looks like I'm still not out of hot water though...
Private Sub Command1_Click()
Call SpeakIt("Hello Michael", 1, "")
End Sub

Results in me getting a error on the Voice.Speak Txt, SVSFlagsAsync
line. It says "Run-time error 91. Object variable or With block var-
iable not set."
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx
On Tue, 22 Nov 2005 16:03:54 GMT, polite person <si*****@ease.com>
wrote:
On Tue, 22 Nov 2005 10:46:11 -0500, MLH <CR**@NorthState.net> wrote:
I get an error at compile time on the following line
Dim Voice As SpVoice
telling me user-defined type not defined.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx


I see that I have a reference to the Microsoft Speech Object Library.
Open a code module, go to Tools/ References and see if you can find it in the list, and check it.
If not try to browse to sapi.dll.


Nov 23 '05 #16
On Tue, 22 Nov 2005 12:54:50 -0500, MLH <CR**@NorthState.net> wrote:

Looks like I'm still not out of hot water though...
Private Sub Command1_Click()
Call SpeakIt("Hello Michael", 1, "")
End Sub

Results in me getting a error on the Voice.Speak Txt, SVSFlagsAsync
line. It says "Run-time error 91. Object variable or With block var-
iable not set."


You need to call InitialiseVoice at the start.

Nov 23 '05 #17
MLH
Private Sub Command1_Click()
Call InitialiseVoice
Call SpeakIt("Hello Michael", 1, "")

End Sub

Works like a charm. 'preciate it much.
Nov 23 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris | last post by:
Hi, I am running VB6 under windows XP Professional.. I added the 'Microsoft Direct Text-To-Speech' component, named it spkSpeak and added the following code in Form(Load): spkSpeak.Speak "You...
10
by: David ROBERT | last post by:
Hello, I need to read data from a MS Access database. The program (reader) is installed on a linux box and is written in python langage. The database is MS Access 2002 installed on a Win XP box...
7
by: NewbieJon | last post by:
I am attempting to send the variable "sComputerName" from my ActiveX script to "GetInfo.asp" using javascript. (Having been advised this is the way to get my ActiveX variable into my ASP script) ...
2
by: Ronny Sigo | last post by:
Hello all, I a struggling for a few days now to find a way to send automated mail. I succeeded except that MS Outlook always gives me those 2 stupid warnings that 1) a "program tries to get...
3
by: JimF | last post by:
I need to scan a couple of hundred databases in several directories to locate all code that uses a particular function, but cannot figure out how to read the Form or Module text itself. I am...
0
by: David M | last post by:
I am attempting to access the text to speech SDK via. C#. I setup a reference to the "Microsoft Voice Text" Control (vtext.dll) and I added the following code: HTTSLib.TextToSpeechClass v = new...
5
by: news.microsoft.com | last post by:
Hello How can I access another application window's Text? It is ilistview if seen by spy++. I know we have to get the windows handle and read the text.
17
by: DP | last post by:
hi, is there a way to send an e-mail to a customer, using ms access?? or some kind of automated mail merge, so the user only has to review the body, and click send? ive got a customer table,...
0
by: Alan Carpenter | last post by:
I'm curious about getting to the text of procedures in a database other than the current database without a new instance of Access. Note I don't want to execute or call anything, I just want to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.