Invoke VBA - trust access and cannot run macro error

Hi Everyone,

I am getting the below error when using Invoke VBA activity in my Studio X project. I am trying to get the hyperlink URL value stored in excel rows and trying to use the VBA script to get the value returned.

The error is the following:
“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: Cannot run the macro ‘GetURL’. The macro may not be available in this workbook or all macros may be disabled.”

I’ve already made sure that Excel is correctly set but I still get the error. I have also tried the method name with/without quotes as well.
I’m attaching screenshot of the VBA function, Excel settings & UI Path Invoke VBA activity as well (unable to attach more than 1 image as I am a new user).

Any help is appreciated. Thanks in advance.

1 Like

HI @santosh.kannan

Welcome to Uipath community

Have you done all the things in the below steps :

Step 1 Open an Empty excel or any excel file
Step 2 Goto File-> Option
Step 3 Goto Trust Center → Trust Center Settings → Trusted Locations
Step 4 Click on Add new Location and browse for the folders (Project Location) and check the Sub folder of this location also trusted and click on ok
Step 5 The Location will be added in the list of trusted location and click on Ok
Step 6 Goto Trust Center → Trust Center Settings → Macro Setting, enable the Trust access to VBA project object model and click on Ok

Regards
Gokul

1 Like

Hi @Gokul001 ,

I have done Step 5 and Step 6(i had this setting enabled already) but still getting the same error.

1 Like

Have you done Step 4? @santosh.kannan

Yes I have done Step 4 to add the location of the Project Folder as a trusted location and check to include sub-folder.

@Gokul001 im still facing the issue, is there anything else i can try?

Did you get this resolved? I am facing the same issue.

I figured out my issue. I would get this error if I created a txt file within Studio and then used it within the invoke VBA activity. I had to open Notepad, create the VBA code, then save the file to the project. That is the only way I could get around the error. Even after doing that, if I opened the txt file within Studio, the error would return. Has to be a bug in Studio.

11 Likes

@Phillip_Williams , Thanks for bringing this topic up. I ran into this error recently as well. In my case, I found that I had accidentally introduced a syntax error into the vba code when I edited it in notepad to add arguments ( Double) instead of ( as Double).

It appears that at least in my case, UiPath is throwing the wrong error (i.e. the one about enabling Trust…) instead of something about the fact that the vba itself has an error in it.

2 Likes

I also had the same issue when I edited VBA/txt file in UiPath Studio, so it is clearly a bug inside UiPath studio.

2 Likes

Save the notepad with .vbs .
It may work

2 Likes

Thank you! Your comment helped me a lot!

2 Likes

Hi I am getting this same error as well. Anyone resolved this bug?

@Tushar_Karkera,

If you tried all the other solutions. this is the fix

Thanks,
Ashok :slight_smile:

Sry I didn’t get it.

It means,

Don’t open or edit your vba script file from UiPath studio.

If you touched the file from studio, delete the script text file and create new from notepad or any other text file editor.

That’s it.

Thanks,
Ashok :slightly_smiling_face:

Yes I tried this but still not working.I had some error with excel file I deleted that recreated new excel file and the issue got resolved thanks anyway.

1 Like