I'm trying to programatically test if the Microsoft Speech Object Library is
selected and then if it is not I'd like to set it.

I've tried error trapping each side of a Dim but that didn't work:
On error reume next
Voc = SpeechLib.SpVoice
On error resume 0
If voc is nothing then '... let me know or fix it

Due to security levels I hope I can do this without
Application.VBE.ActiveVBProject.References

Can anyone shine some light on this one?

Thanks!
Mike

Re: how to determine if a reference is selected and set it if it is no by Jonathan

Jonathan
Thu Jan 10 16:40:32 PST 2008


"MikeB77" <MikeB77@discussions.microsoft.com> wrote in message
news:814BA0F2-07A5-42B5-8FCA-E4BE1F0C70E8@microsoft.com...
> I'm trying to programatically test if the Microsoft Speech Object Library
> is
> selected and then if it is not I'd like to set it.
>
> I've tried error trapping each side of a Dim but that didn't work:
> On error reume next
> Voc = SpeechLib.SpVoice
> On error resume 0
> If voc is nothing then '... let me know or fix it
>
> Due to security levels I hope I can do this without
> Application.VBE.ActiveVBProject.References
>
> Can anyone shine some light on this one?


Use late binding instead. In other words, use GetObject or CreateObject to
assign the object to a variable declared as an Object.

Then if the CreateObject call fails (i.e. the object is Nothing after the
call) you can act accordingly.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup



Re: how to determine if a reference is selected and set it if it i by MikeB77

MikeB77
Fri Jan 11 02:28:01 PST 2008

Thanks for your assistance. I should have thought of that.
But when I try:
set voc = CreateObject("SpeechLib.SpVoice") or
Set Voc = CreateObject("SpVoice")
or similar I get error 429: ActiveX can't create object. I've read that
ActiveX components can't create user defined funcitons
(http://support.microsoft.com/kb/184898). So am I going about this the wrong
way?

Thanks
Mike



>
> Use late binding instead. In other words, use GetObject or CreateObject to
> assign the object to a variable declared as an Object.
>
> Then if the CreateObject call fails (i.e. the object is Nothing after the
> call) you can act accordingly.
>
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
>
>
>

Re: how to determine if a reference is selected and set it if it i by Steve

Steve
Fri Jan 11 07:44:12 PST 2008

Mike,

This may be a different object but what I use from vbScript also works in
VBA routines. See if you can make this do what you want.

strText = "This is a test"
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Speak strText


Steve



"MikeB77" <MikeB77@discussions.microsoft.com> wrote in message
news:4149EB41-EF0E-471E-9888-A5910567B4D8@microsoft.com...
> Thanks for your assistance. I should have thought of that.
> But when I try:
> set voc = CreateObject("SpeechLib.SpVoice") or
> Set Voc = CreateObject("SpVoice")
> or similar I get error 429: ActiveX can't create object. I've read that
> ActiveX components can't create user defined funcitons
> (http://support.microsoft.com/kb/184898). So am I going about this the
> wrong
> way?
>
> Thanks
> Mike
>
>
>
>>
>> Use late binding instead. In other words, use GetObject or CreateObject
>> to
>> assign the object to a variable declared as an Object.
>>
>> Then if the CreateObject call fails (i.e. the object is Nothing after the
>> call) you can act accordingly.
>>
>>
>> --
>> Regards
>> Jonathan West - Word MVP
>> www.intelligentdocuments.co.uk
>> Please reply to the newsgroup
>>
>>
>>



Re: how to determine if a reference is selected and set it if it i by MikeB77

MikeB77
Sat Jan 12 01:02:01 PST 2008

Thanks Steve. That may be a different object, or just a easier way to SAPI:
either way its got it nailed. No setting references required!

Mike

"Steve Yandl" wrote:

> Mike,
>
> This may be a different object but what I use from vbScript also works in
> VBA routines. See if you can make this do what you want.
>
> strText = "This is a test"
> Set objVoice = CreateObject("SAPI.SpVoice")
> objVoice.Speak strText
>
>
> Steve
>
>
>
> "MikeB77" <MikeB77@discussions.microsoft.com> wrote in message
> news:4149EB41-EF0E-471E-9888-A5910567B4D8@microsoft.com...
> > Thanks for your assistance. I should have thought of that.
> > But when I try:
> > set voc = CreateObject("SpeechLib.SpVoice") or
> > Set Voc = CreateObject("SpVoice")
> > or similar I get error 429: ActiveX can't create object. I've read that
> > ActiveX components can't create user defined funcitons
> > (http://support.microsoft.com/kb/184898). So am I going about this the
> > wrong
> > way?
> >
> > Thanks
> > Mike
> >
> >
> >
> >>
> >> Use late binding instead. In other words, use GetObject or CreateObject
> >> to
> >> assign the object to a variable declared as an Object.
> >>
> >> Then if the CreateObject call fails (i.e. the object is Nothing after the
> >> call) you can act accordingly.
> >>
> >>
> >> --
> >> Regards
> >> Jonathan West - Word MVP
> >> www.intelligentdocuments.co.uk
> >> Please reply to the newsgroup
> >>
> >>
> >>
>
>
>

Re: how to determine if a reference is selected and set it if it i by Steve

Steve
Sat Jan 12 07:36:17 PST 2008

Mike,

You're welcome. I've only used the object sparingly and only to speak short
lines but you can do other things like play a .wav file. For reference,
this article might be of use:
http://www.microsoft.com/technet/scriptcenter/funzone/games/sapi.mspx

Steve Yandl



"MikeB77" <MikeB77@discussions.microsoft.com> wrote in message
news:A9C1C637-4D08-4603-933D-8AF31B6B52AD@microsoft.com...
> Thanks Steve. That may be a different object, or just a easier way to
> SAPI:
> either way its got it nailed. No setting references required!
>
> Mike
>
> "Steve Yandl" wrote:
>
>> Mike,
>>
>> This may be a different object but what I use from vbScript also works in
>> VBA routines. See if you can make this do what you want.
>>
>> strText = "This is a test"
>> Set objVoice = CreateObject("SAPI.SpVoice")
>> objVoice.Speak strText
>>
>>
>> Steve
>>
>>
>>
>> "MikeB77" <MikeB77@discussions.microsoft.com> wrote in message
>> news:4149EB41-EF0E-471E-9888-A5910567B4D8@microsoft.com...
>> > Thanks for your assistance. I should have thought of that.
>> > But when I try:
>> > set voc = CreateObject("SpeechLib.SpVoice") or
>> > Set Voc = CreateObject("SpVoice")
>> > or similar I get error 429: ActiveX can't create object. I've read
>> > that
>> > ActiveX components can't create user defined funcitons
>> > (http://support.microsoft.com/kb/184898). So am I going about this the
>> > wrong
>> > way?
>> >
>> > Thanks
>> > Mike
>> >
>> >
>> >
>> >>
>> >> Use late binding instead. In other words, use GetObject or
>> >> CreateObject
>> >> to
>> >> assign the object to a variable declared as an Object.
>> >>
>> >> Then if the CreateObject call fails (i.e. the object is Nothing after
>> >> the
>> >> call) you can act accordingly.
>> >>
>> >>
>> >> --
>> >> Regards
>> >> Jonathan West - Word MVP
>> >> www.intelligentdocuments.co.uk
>> >> Please reply to the newsgroup
>> >>
>> >>
>> >>
>>
>>
>>