CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Jun 2021
    Posts
    1

    Speak (VBA) - Method or data member not found

    Suddenly I cannot get .Speak to work without the above error. The macro below worked fine, until it didn't and started getting this error. Suggestions?

    Code:
    Sub Range()
    '
    ' Range Macro
    '
    '
    Dim rng As Word.Range
    Dim SearchString As String
    'Dim Speak As SpVoice
    Dim Speech As SpeechLib.SpVoice
    Set rng = ActiveDocument.Content
    Set Speech = New SpVoice
    SearchString = """"
    
    With rng.Find
    'rng.Find.ClearFormatting
        Do While .Execute(findText:=SearchString, Forward:=True) = True
          rng.MoveEndUntil (".?,;!")
        
    'Speech.Speak "Hello"
     
          Application.Speech.Speak "speaking", SVSFlagsAsync '+ SVSFPurgeBeforeSpeak
       'Speak "speaking", SVSFlagsAsync '+ SVSFPurgeBeforeSpeak
           MsgBox rng.Text
          Exit Do
          rng.Collapse wdCollapseEnd
        Loop
        
    End With
    
    End Sub
    Last edited by VictorN; June 8th, 2021 at 01:44 AM. Reason: added CODE tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured