Welcome to MSDN Blogs Sign in | Join | Help

Word to audible speech

Here’s some interesting code to run. It starts Microsoft Word and binds some Fox code to some Word events.

Type some text into the document. Select some text.

 

When the Selection Change event occurs, the Foxpro code creates the speech API object and speaks out loud the currently selected text.

 

 

 

ow = CREATEOBJECTex("word.application","","")

omyevents = CREATEOBJECT('myevents')

omyevents.ow = ow

?EVENTHANDLER(ow,omyevents)

ow.visible = .t.

ow.Activate

ow.Documents.Add

*ow.Quit

 

DEFINE CLASS myevents as Custom

      oSapi=0

      implements applicationevents2 IN "C:\Program Files\Microsoft Office\OFFICE11\msword.olb"

      ow = .null.

      PROCEDURE applicationevents2_startup()

            ?PROGRAM()

      PROCEDURE applicationevents2_quit

            ?PROGRAM()

      procedure applicationevents2_DocumentBeforeClose(Cancel,Doc)

            ?PROGRAM()

      procedure DocumentBeforeClose(Cancel,Doc)

            ?PROGRAM()

      procedure applicationevents2_DocumentBeforePrint(Cancel,Doc)

            ?PROGRAM()

      procedure applicationevents2_DocumentBeforeSave(Doc,SaveAsUI,Cancel)

            ?PROGRAM()

      procedure applicationevents2_DocumentChange

            ?PROGRAM()

      procedure applicationevents2_DocumentOpen(Doc)

            ?PROGRAM()

      procedure applicationevents2_NewDocument(Doc)

            ?PROGRAM()

      procedure applicationevents2_WindowActivate(Doc,Wn)

            ?PROGRAM()

      procedure applicationevents2_WindowBeforeDoubleClick(Sel,Cancel)

            ?PROGRAM()

      procedure applicationevents2_WindowBeforeRightClick(Sel,Cancel)

            ?PROGRAM()

      procedure applicationevents2_WindowDeactivate(Doc,Wn)

            ?PROGRAM()

      procedure applicationevents2_WindowSelectionChange(Sel)

            ?PROGRAM(),sel.text

            IF sel.start < sel.end

                  IF VARTYPE(this.oSapi)!='O'

                        this.oSapi=CREATEOBJECT("SAPI.spVoice.1")

*                       this.oSapi.Voice=this.oSapi.GetVoices().Item(1)

                  ENDIF

                  this.oSapi.Speak(sel.text)

*                sel.InsertAfter("Fox!")

*!*               mtmp = sel.text

*!*               sel.text=STRTRAN(mtmp,"good","Great!")

            endif

      PROCEDURE destroy

            ?PROGRAM()

            IF !ISNULL(this.ow)

                  ?EVENTHANDLER(this.ow,this,.t.)

            ENDIF

ENDDEFINE

 

Published Monday, May 16, 2005 1:10 AM by Calvin_Hsia
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Word to audible speech

Monday, May 16, 2005 7:33 AM by Alex Feldstein
Great sample Calvin.

Note that this uses MS-Word 11 (Office 2003). For previous versions you'd have to adjust accordingly. For example, at work I use Office 2000 (Office9) so the path there would be:

implements applicationevents2 IN "C:\Program Files\Microsoft Office\OFFICE\msword9.olb"

# re: Word to audible speech

Wednesday, May 18, 2005 1:09 PM by Ken Weber
Can this be done without hardcoding a path to the OLB?

# re: Word to audible speech

Thursday, May 19, 2005 10:08 AM by Thierry
implements applicationevents2 IN "Word.Application"

# re: Word to audible speech

Thursday, June 16, 2005 6:02 AM by George
Hi, Extremely neat! is there an equivalent SAPI .DLL for W2K O-S's?

# Payday Loan

Sunday, March 19, 2006 12:58 PM by Payday Loan
Very nice and informative website.

# hi

Saturday, April 29, 2006 12:19 PM by Katrina
Very nice website with a lot of informative response from members

# buy xanax

Saturday, June 03, 2006 1:03 AM by buy xanax
i like your website very much but please do get us more information about it

# How does EventHandler work? IConnectionPoint!

Wednesday, June 14, 2006 7:53 PM by Calvin Hsia's WebLog
The EventHandler function allows you to connect some code to an object’s event interface. For example,...

# re: Word to audible speech

Friday, December 08, 2006 4:53 AM by used-car

Nice job...

<a href="http://used-car-dealer-dallas.u4fgf.info "> used car dealer dallas</a>

# re: Word to audible speech

Saturday, December 09, 2006 10:43 AM by Britney

Hi, nice very nice page..!

<a href='http://www.blogpostworld.org/blog-code-music-site-web.html'>blog code music site web</a>

<a href='http://www.blogpostworld.org/blog-from-music.html'>blog from music</a>

<a href='http://www.blogpostworld.org/blog-music-music.html'>blog music music</a>

# re: Word to audible speech

Tuesday, December 12, 2006 10:43 PM by None

Hello, Nice site. I am able to learn many stotras. Very good work.  

http://company-christmas-party.orhat.info

# doyen Maastricht

Thursday, December 14, 2006 7:55 AM by doyen Maastricht

thoughts from a professional developer

I do not agree. Go to http://www.bookshotel.info/polygeny_Netherlands/homicidal_Holland/doyen_Maastricht_1.html

# re: Word to audible speech

Thursday, December 14, 2006 11:40 AM by Bill

When all else fails, read the instructions

<a href='http://cingular-prepaid-wireless.rjnrh3.info/billing-cingular-wireless.html'>billing cingular wireless</a>

# re: Word to audible speech

Friday, December 15, 2006 7:39 PM by used-car

Nice job...

<a href="http://used-car-dealer-dallas.u4fgf.info "> used car dealer dallas</a>

# re: Word to audible speech

Monday, December 18, 2006 2:10 AM by Alex

Hi... there...

<a href='http://wrongful-death-attorney.blogpostworld.org/wrongful-death-attorney-melbourne.html'>wrongful death attorney melbourne</a>

# re: Word to audible speech

Wednesday, December 20, 2006 12:33 PM by None

Hello, This site is simply very good...  

http://sapasor.orgfree.com/

# re: Word to audible speech

Saturday, January 06, 2007 5:42 AM by None

# re: Word to audible speech

Saturday, January 13, 2007 11:19 PM by None

Hello, Very Excellent site.  

http://supyw.thehostcity.com/buy-valium-without-prescription/  

Thanks!

# re: Word to audible speech

Sunday, January 14, 2007 7:42 AM by Max

Hi... thanks...

<a href=' http://coffee-maker.belon.org/bunn-coffee-maker-repair-part.html '>bunn coffee maker repair part</a>

<a href=' http://coffee-maker.belon.org/bunn-coffee-maker-recall.html '>bunn coffee maker recall</a>

# re: Word to audible speech

Tuesday, January 23, 2007 12:01 AM by Allos

Hi... thanks...

<a href=' http://dog-training-equipment.belon.org/sled-dog-training-equipment.html '>sled dog training equipment</a>

<a href=' http://dog-training-equipment.belon.org/dog-training-equipment.html '>dog training equipment</a>

# re: Word to audible speech

Sunday, January 28, 2007 9:37 PM by game

Nice site

<a href=' http://shurl.net/2nz '> game </a>

# re: Word to audible speech

Tuesday, January 30, 2007 5:48 PM by Sasha

thanks...

<a href=' http://ford-truck.fw3gd.info/1949-ford-truck.html '>1949 ford truck</a>

<a href=' http://ford-truck.fw3gd.info/san-antonio-ford-truck.html '>san antonio ford truck</a>

# re: Word to audible speech

Friday, February 09, 2007 1:28 PM by Anderson

# re: Word to audible speech

Monday, February 12, 2007 10:43 PM by kitchen

# re: Word to audible speech

Tuesday, February 13, 2007 1:05 PM by car

Nice site

<a href= http://tsbgyk3q.tripod.com/donate-used-car/car-donate-infocus-used.html >car donate infocus used</a>

# re: Word to audible speech

Saturday, February 17, 2007 11:34 AM by home

nice  <a href=' http://homebusiness.belon.org '> home business </a>

# re: Word to audible speech

Friday, February 23, 2007 3:49 PM by car

Nice site

<a href= http://used-car-phoenix.cashwits.org/map.html >car used</a>

# re: Word to audible speech

Sunday, February 25, 2007 4:34 AM by dallas

nice site <a href= http://tsbgyk3q.tripod.com/used-car-dallas > used car dallas </a>

# re: Word to audible speech

Sunday, February 25, 2007 3:34 PM by Oppers

# re: Word to audible speech

Monday, February 26, 2007 3:23 PM by batt

nice site <a href= http://battery-laptop.d3ald.info > battery laptop </a>

# re: Word to audible speech

Wednesday, February 28, 2007 5:07 AM by dJEIraV

# re: Word to audible speech

Friday, March 02, 2007 3:37 PM by HHeYrUT

# re: Word to audible speech

Wednesday, March 14, 2007 2:49 PM by HJioJYq

# re: Word to audible speech

Saturday, March 17, 2007 7:22 AM by fQIalYb

nice site

<a href= "http://acer-laptop.cashwits.org/acer-laptop-memory.html" >acer laptop memory</a>

<a href= "http://acer-laptop.cashwits.org/acer-laptop-rate.html" >acer laptop rate</a>

# re: Word to audible speech

Sunday, March 18, 2007 6:47 PM by BfUufIM

# re: Word to audible speech

Wednesday, March 21, 2007 4:12 AM by CtOIHik

nice site

<a href= http://pills.belon.org/claritin-and-blood-pressure >claritin and blood pressure</a>

<a href= http://kasta.belon.org/allergy-medication-singular >allergy medication singular</a>

# re: Word to audible speech

Friday, March 23, 2007 11:27 AM by fpOikos

No, no, no

<a href= http://pills.belon.org/com-singular >com singular</a>

<a href= http://pills.belon.org/claritin-kid >claritin kid</a>

# re: Word to audible speech

Sunday, April 01, 2007 2:18 PM by diet

Nice site

<a href="http://tradewits.org/dog-food-natural ">dog food natural</a>

# re: Word to audible speech

Sunday, April 01, 2007 5:59 PM by vase

Great site <a href="http://pxmgywdp.tripod.com/fast-food ">fast food</a>

# re: Word to audible speech

Saturday, April 07, 2007 12:06 PM by diet

Nice site

<a href=" http://zr2d4nmn.tripod.com/buy-online-wii "> buy online wii</a>

# Good site,Chauncey Wilson

Wednesday, April 18, 2007 11:56 AM by healthqtw,healthqtw,healthqtw

The Best Catalog.

<a href=http://healthpiece.info/>Real">http://healthpiece.info/>Real Catalog</a>[url=http://healthpiece.info/]The Real Catalog[/url]

# I do not think so

Tuesday, August 14, 2007 12:59 PM by warsaw apartments

thoughts from a professional developer

I do not agree. Go to http://apartments.waw.pl/

# foxpro.catalyst ?? &raquo; Blog Archive &raquo; VisualFoxpro rocks&#8230; and talks.

# Good site

Thursday, March 06, 2008 5:43 PM by gonxe

<a href=" http://school-ut3.0catch.com/ ">Bible high school literature</a>

# Good site

Thursday, March 06, 2008 5:46 PM by aisrx

<a href=" http://school-ut3.0catch.com/ ">Bible high school literature</a>

# Good site

Wednesday, April 09, 2008 3:02 PM by edalo

I like this site! <a href=" http://free-8-a2.0catch.com/ ">Free graphic organizers</a> wokrg

# Interaction : EVENTHANDLER() ou BindEvent() | hilpers

Thursday, January 22, 2009 10:16 AM by Interaction : EVENTHANDLER() ou BindEvent() | hilpers

# Calvin Hsia s WebLog Word to audible speech | Paid Surveys

# Calvin Hsia s WebLog Word to audible speech | Wood TV Stand

# Calvin Hsia s WebLog Word to audible speech | Wood TV Stand

# Calvin Hsia s WebLog Word to audible speech | Weak Bladder

# Calvin Hsia s WebLog Word to audible speech | Green Tea Fat Burner

# Calvin Hsia s WebLog Word to audible speech | Quick Diets

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker