[Help Needed] Cannot Run VBA Macro via Invoke VBA — “Trust Access to VBA Project Object Model” Already Enabled

Hi all,

I’m currently working on my final project for graduation, and I’m using UiPath to automate an Excel-based process. The workflow includes:

  1. Reading and merging two Excel files
  2. Creating a new .xlsm file with two new sheets
  3. Running a VBA macro to format the sheets
  4. Sending the final file to Telegram

The macro runs perfectly if I open the Excel file manually and run the macro from inside Excel. However, when I try to run the same macro using Invoke VBA in UiPath, I get this error:

Invoke VBA: In order for this activity to work, Trust Access to the VBA project object model must be enabled…

Of course, I already:

  • Enabled all macros
  • Checked “Trust access to the VBA project object model” in Trust Center settings
  • Tried restarting Excel and UiPath
  • Ensured file is .xlsm and saved before invoking

This is my personal laptop, and there’s no IT/admin restriction, antivirus, or GPO blocking access.

I also tried this registry key (AccessVBOM = 1), but still no success:

pgsql

CopyEdit

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\<version>\Excel\Security

:wrench: Questions:

  1. Why does this error persist even though all trust settings are enabled?
  2. Is there a more reliable way to trigger macros from UiPath?
  3. Would Workbook.RunMacro or UI automation be more appropriate than Invoke VBA?
  4. Any known limitations with Office 365 in headless/automated mode?

Thanks in advance! I really need this to work fully automated for my graduation project :folded_hands:

@nashwasabila11,

If you have the VBA code in the same XLSM file use Execute Macro activity.

If the code is in text file, create a text file in File Explorer and paste the code in it and save it. Now do not open the code text file from studio.

Directly refer the code text file path from Invoke VBA activity.

Hi @nashwasabila11

Can you try using classic activities.

This is just an example of flow:

Inside Append Items in Collections pass the necessary values which you are using in the Macro.

Hope it helps!!

Thank you so much for your help!
Your explanation really helped me understand the issue. I followed your suggestion — created a new .txt file using Notepad, pasted the VBA code there, and made sure not to open it from UiPath Studio. And guess what? It finally worked!

1 Like

@nashwasabila11,

Glad to hear! Cheers! :slight_smile:

1 Like

Thank you for your suggestion!
I really appreciate you taking the time to help. I ended up solving the issue using another approach — by creating a new .txt file for the VBA script (outside UiPath Studio), and that worked perfectly.

But I’ll definitely keep your method in mind for future projects. Thanks again for your support! :blush:

1 Like

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