# Add VBA code into invoke code activity

**URL:** <https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958>\
**Category:** Academy Feedback\
**Tags:** excel, system, activities\
**Created:** [March 30, 2020, 5:50am UTC](https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958 "2020-03-30T05:50:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![trunghai](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/trunghai/32/177411_2.png) [@trunghai](https://forum.uipath.com/u/trunghai)\
**Post date:** [March 30, 2020, 5:50am UTC](https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958/1 "2020-03-30T05:50:27Z")

</div>

Hi Everyone.

I have a VBA code as below.. The purpose of this VBA code to find & highlight special text “INV” which it found in cell by cell within range “A2:A4” in excel file.

I know how to use invoke VBA activity. But i dont know about the Invoke Code Activity and declare arguments .

Pls check and make a xaml file.. i want to check and study from this.

Thanks in advance!

Dim strTest As String  
Dim strLen As Integer  
strTest = “INV”  
strLen = Len(strTest)  
For Each Cell In Sheet1.Range(“A2:A4”)  
If InStr(Cell, strTest) \> 0 Then  
Cell.Characters(InStr(Cell, strTest), strLen).Font.Color = vbRed  
Cell.Characters(InStr(Cell, strTest), strLen).Font.Bold = True  
End If  
Next

[file.xlsx](https://forum.uipath.com/uploads/short-url/rjVgWhiI3eG7TgkxIpMBRPG2JUd.xlsx) (8.0 KB)

---

<div class="post-metadata">

**Author:** ![Cristian\_Bardas](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/cristian_bardas/32/60932_2.png) [@Cristian\_Bardas](https://forum.uipath.com/u/Cristian_Bardas)\
**Post date:** [March 30, 2020, 5:56am UTC](https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958/2 "2020-03-30T05:56:16Z")

</div>

Please don’t open a new topic for the same question.

Here you go, it should be what you need.

[ExcelVBA.zip](https://forum.uipath.com/uploads/short-url/gl5RJ6vXtg63ABhJfaqDZkiFuUz.zip) (24.4 KB)

---

<div class="post-metadata">

**Author:** ![trunghai](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/trunghai/32/177411_2.png) [@trunghai](https://forum.uipath.com/u/trunghai)\
**Post date:** [March 30, 2020, 5:59am UTC](https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958/3 "2020-03-30T05:59:36Z")

</div>

Hi Bro @Cristian_Bardas

Thanks you but it not as my question.

I have known how to use Invoke VBA activity… But i dont know how to use Invoke Code Activity.

I want to use Invoke Code Activity for this case.

Thanks you so much!

---

<div class="post-metadata">

**Author:** ![JCaravaca](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jcaravaca/32/263381_2.png) [@JCaravaca](https://forum.uipath.com/u/JCaravaca)\
**Post date:** [March 30, 2020, 6:03am UTC](https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958/4 "2020-03-30T06:03:52Z")

</div>

Invoke Code is strictly for [VB.NET](http://VB.NET) code.  
VBA runs on an Excel workbook. If you absolutely have to run VBA code on a workbook, it either needs to have that code in a Sub inside that workbook, or you can make an empty workbook and pack that code in it (adding enough code to open and close that other workbook)

---

<div class="post-metadata">

**Author:** ![trunghai](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/trunghai/32/177411_2.png) [@trunghai](https://forum.uipath.com/u/trunghai)\
**Post date:** [March 30, 2020, 6:07am UTC](https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958/5 "2020-03-30T06:07:37Z")

</div>

Thanks you very much!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [April 2, 2020, 6:07am UTC](https://forum.uipath.com/t/add-vba-code-into-invoke-code-activity/206958/6 "2020-04-02T06:07:40Z")

</div>

Closed on April 2, 2020, 6:07am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
