Not able to run Invoke VBA Function on Windows 11|

Hello,

I am facing this issue on Windows 11 machine; process was working fine on Window 10.

Here is the exception:

In order for this activity to work, Trust Access to the VBA project object model must be enabled from Excel (File > Options > Trust Center > Trust Center Settings > Macro Settings > Select the Trust Access to the VBA project object model check box)

UiPath.Excel.ExcelException: In order for this activity to work, Trust Access to the VBA project object model must be enabled from Excel (File > Options > Trust Center > Trust Center Settings > Macro Settings > Select the Trust Access to the VBA project object model check box) —> System.Runtime.InteropServices.COMException: Programmatic access to Visual Basic Project is not trusted
at Microsoft.Office.Interop.Excel._Workbook.get_VBProject()
at UiPath.Excel.WorkbookApplication.InvokeVBA

I have enabled the option in trust center.

@Ranveer_S_Thakur,

If everything is fine from excel settings, just save your VBA code text file with correct encoding like explained in this solution.

1 Like

@Ranveer_S_Thakur

Create a new text file in a different location and copy the code to it

Then delete the old file and move the created file to required location and check

Cheers

1 Like