Cant excecute Excel VBA Macro

Hi all,

I’m relatively new to automating with UiPath and just started a project requiring a VBA macro to be executed in a report that is automatially downloaded. As the file is always a new one each time the RPA is run, the Macro has to be stored in my personal macro workbook to be executed.

I’m using the Excel Application Scope activity and the execute Macro activity within it.

Which looks like this:

image

Running this leads to the following error:

20.10.2+Branch.master.Sha.cf481ddc1ae94ab83e743f85d96fbfeca8fc705c

Source: Execute Macro

Message: Microsoft Excel cannot access the file ‘\smtcf01002.rd.corpintra.net\EHRHARY$\data\My Documents\PERSONAL.XLSB’’. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.

Exception Type: System.Runtime.InteropServices.COMException

RemoteException wrapping System.Runtime.InteropServices.COMException: Microsoft Excel cannot access the file ‘\smtcf01002.rd.corpintra.net\EHRHARY$\data\My Documents\PERSONAL.XLSB’’. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
at UiPath.Excel.Activities.ExecuteMacro.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

I would be very greatful if someone could help me with this.

Best
Yannik

Hi @YaEh,
Welcome to the Community!

Is your excel file consists of some remote data? From the error, it seems that some data comes from the external location that macro can’t access.

Hi @YaEh ,

I think you have to pass the file which hold your macro functions and in execute macro you have to pass Function name.

Hope you are doing in the right way.

1 Like

Hi Pawel,
thanks for your reply. That really helped. The issue was that I reference a second file for a vlookup in my VBA macro. However if that file isnt opened excel makes you pick it by a pop up window normally. This seems to where the problem arose from as when I opend this second file and then ran the macro, it worked. Now I only have to figure out how to dynamically reference the second file in my code and I should be fine.

Best
Yannik

1 Like