# Invoke vb code error

**URL:** <https://forum.uipath.com/t/invoke-vb-code-error/239291>\
**Category:** Studio\
**Tags:** system, activities\
**Created:** [July 19, 2020, 6:36pm UTC](https://forum.uipath.com/t/invoke-vb-code-error/239291 "2020-07-19T18:36:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shanewatson](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@shanewatson](https://forum.uipath.com/u/shanewatson)\
**Post date:** [July 19, 2020, 6:36pm UTC](https://forum.uipath.com/t/invoke-vb-code-error/239291/1 "2020-07-19T18:36:14Z")

</div>

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
  .ClearFormatting
  .Text = strText
  .MatchCase = True
  .MatchWildcards = False
  .Execute
End With
ObjSelectText.End = Selection.Range.End - Len(strText)
ObjSelectText.Select

```

End With  
End Sub

 ![Capture](https://global.discourse-cdn.com/uipath/original/3X/4/b/4be554ac8830619c2bf5f6ddf0bbff40c86c45a2.png)

---

<div class="post-metadata">

**Author:** ![avejr748](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/avejr748/32/96165_2.png) [@avejr748](https://forum.uipath.com/u/avejr748)\
**Post date:** [July 20, 2020, 3:14am UTC](https://forum.uipath.com/t/invoke-vb-code-error/239291/2 "2020-07-20T03:14:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GBK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gbk/32/142274_2.png) [@GBK](https://forum.uipath.com/u/GBK)\
**Post date:** [July 20, 2020, 7:48am UTC](https://forum.uipath.com/t/invoke-vb-code-error/239291/3 "2020-07-20T07:48:57Z")

</div>

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