Invoke vb code error

Hi All,
I am tried invoke code and getting these error,can anyone help to resolve this.

Sub SelectARangeOfTexts()
Dim ObjSelectText As Range
Dim strText As String

strText = InputBox(“Enter Marking word(s) here:”, “Select a range of texts”)
Set ObjSelectText = Selection.Range

With Selection
.HomeKey Unit:=wdStory

With Selection.Find
  .Text = strText
  .MatchCase = True
  .MatchWildcards = False
End With
ObjSelectText.End = Selection.Range.End - Len(strText)

End With
End Sub

Hi @shanewatson
Try removing “Sub SelectARangeOfTexts()” and “End Sub”

For Invoke code - no need to define a function/method name. please remove below and try.
Sub SelectARangeOfTexts()
End Sub

1 Like