Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2008

Tip: Looking for answers? Try searching our database.

how to determine if a reference is selected and set it if it is no

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MikeB77 - 10 Jan 2008 10:11 GMT
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
Jonathan West - 11 Jan 2008 00:40 GMT
> I'm trying to programatically test if the Microsoft Speech Object Library
> is
[quoted text clipped - 10 lines]
>
> 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.

Signature

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

MikeB77 - 11 Jan 2008 10:28 GMT
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.
Steve Yandl - 11 Jan 2008 15:44 GMT
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

> Thanks for your assistance. I should have thought of that.
> But when I try:
[quoted text clipped - 15 lines]
>> Then if the CreateObject call fails (i.e. the object is Nothing after the
>> call) you can act accordingly.
MikeB77 - 12 Jan 2008 09:02 GMT
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

> Mike,
>
[quoted text clipped - 26 lines]
> >> Then if the CreateObject call fails (i.e. the object is Nothing after the
> >> call) you can act accordingly.
Steve Yandl - 12 Jan 2008 15:36 GMT
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

> Thanks Steve.  That may be a different object, or just a easier way to
> SAPI:
[quoted text clipped - 35 lines]
>> >> the
>> >> call) you can act accordingly.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.