3

I want to be able to create a macro that will start text-to-speech on the text that is in the presenters notes. I will be applying the macro to a ActiveX button that will allow the user to start the reading and eventaully I would like to time the animations of the slides to the speech.

I have sucess in Excel VBA in being able to write out the command to speak a cell with:

application.speech.speak (sheet1.cells(1,1))

and I found a code that will enter text into the speaker notes section for all slides.

Sub AddTextAllSpeakerNotes()
  Dim sld As Slide
  For Each sld In ActivePresentation.Slides
    sld.NotesPage.Shapes.Placeholders(2).TextFrame.TextRange = ""
  Next sld
End Sub

I have added the Microsoft Speech Object Library reference, but I can never get the VBA to recognize the speech commands and auto-complete any commands that will help me figure out how to get any further.

How can I write a code that will apply the text-to-speech command to the speaker notes section of a particular slide.

L42
  • 19,427
  • 11
  • 44
  • 68
OAR617
  • 79
  • 9
  • Try adding reference to Excel. Bind (early) the Excel Object and execute the `Speech` command using the exact same code you used above but this time, pulling the information from your `TextFrame`. – L42 Mar 12 '15 at 23:45

1 Answers1

5

As commented, you can try this:

Dim XL As Excel.Application
Set XL = New Excel.Application

XL.Speech.Speak "I was able to make power point speak"

Provided you added reference to:

Microsoft Excel XX.X Object Library

Once you've bound Excel to PowerPoint, you can directly use its methods from there.
In above code, you can simply replace the argument with the actual PPT object that contains the string you want spoken. HTH.

L42
  • 19,427
  • 11
  • 44
  • 68
  • Thank you! I was able to get it do exactly what I wanted it to do. – OAR617 Mar 22 '15 at 14:25
  • @OAR617 Glad it did. Btw, please see [accepting answers](http://stackoverflow.com/help/someone-answers) as one way of saying *thank you* in our community. It was also well explained [here](http://stackoverflow.com/tour). – L42 Mar 22 '15 at 22:27