Hi There - I’m attempting to use an invoke VBA command in a StudioX script to call on text scripts that I’ve saved in a project folder. I’m trying to structure the project this way, as I want to avoid creating separate macros for each individual file that I am accessing - as I am iterating through several excel files and copying and pasting certain cells. Whenever I try to run it I get the following error, even though I have the box checked it refers to. Image below of my invoke VBA command - I’m probably doing it wrong.
VBA Text file - Sub SelectRange()
’ Select cells A1 to F47 on the active worksheet
Range(“A1:F47”).Select
End Sub
Error message below -
23.10.5+Branch.support-v23.10.Sha.1a13e22180538f0c894f0828e9d5af447df5806e
Source: Invoke VBA
Message: 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)
Exception Type: UiPath.Excel.ExcelException
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 ‘SelectRange’. The macro may not be available in this workbook or all macros may be disabled. at Microsoft.Office.Interop.Excel._Application.Run(Object Macro, Object Arg1, Object Arg2, Object Arg3, Object Arg4, Object Arg5, Object Arg6, Object Arg7, Object Arg8, Object Arg9, Object Arg10, Object Arg11, Object Arg12, Object Arg13, Object Arg14, Object Arg15, Object Arg16, Object Arg17, Object Arg18, Object Arg19, Object Arg20, Object Arg21, Object Arg22, Object Arg23, Object Arg24, Object Arg25, Object Arg26, Object Arg27, Object Arg28, Object Arg29, Object Arg30)
at UiPath.Excel.WorkbookApplication.ExecuteMacro(String macroName, IEnumerable1 macroParameters) at UiPath.Excel.WorkbookApplication.InvokeVBA(String codeFilePath, String entryMethodName, IEnumerable
1 entryMethodParams)
at UiPath.Excel.Activities.Business.InvokeVBAX.ExecuteDoWork(ActivityContext context, ExecuteVBADescriptor descriptor)
— End of inner exception stack trace —
at UiPath.Excel.Activities.Business.InvokeVBAX.ExecuteDoWork(ActivityContext context, ExecuteVBADescriptor descriptor)
at UiPath.Shared.Activities.BaseParentActivityWithDescriptor`2.OnCompleted(NativeActivityContext context, ActivityInstance _)
at System.Activities.Runtime.ActivityCompletionCallbackWrapper.Invoke(NativeActivityContext context, ActivityInstance completedInstance)
at System.Activities.Runtime.CompletionCallbackWrapper.CompletionWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)