This is a macro to demonstrate text to speech capabilities. A userForm pops up asking for text. The user types in any text and
the user's computer will read the text aloud. Pressing enter triggers the text to speech subroutine and then the userForm is cleared. There are more simple macros on the
SolidWorks Macros page.

- Dim speaks, speech
- Sub main()
- UserForm1.Show
- End Sub
- Sub sayThis(sp As String)
- Set speech = CreateObject("sapi.spvoice")
- speech.Speak sp
- End Sub

- Private Sub CommandButton1_Click()
- End
- End Sub
- Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
- If KeyCode = 13 Then
- KeyCode = 0 'this line keeps the focus from shifting away from Textbox1'
- speaks = TextBox1.Text
- TextBox1.Text = ""
- sayThis (speaks)
- End If
- End Sub