I am deleting an Excel sheet using the “Delete Sheet (Specify Sheet Name)” in UiPathTeam.Excel.Activities on Windows. During this process, I encountered the following error with a specific Excel file:
“Cannot run the macro ‘DeleteSheet’. This workbook may not have macros enabled or all macros may be disabled.\r\n\r\nSystem.Runtime.InteropServices.COMException: Cannot run the macro ‘DeleteSheet’. This workbook may not have macros enabled or all macros may be disabled. at UiPath.Excel.Activities.InvokeVBA.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)\r\n at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)”
I have tested the same process with other files and it worked fine, so I suspect there is an issue with this file, but I’m not sure where to investigate.
The Excel options are set as follows:
Hello
It’s strange that macros cannot be run even though you have enabled them in the macro settings.
One possibility is that the sheet might be corrupted.
How about creating a new sheet and copying the macro to see if it works?
In reality, the macro is not being executed, and this activity is deleting the sheet.
From the error message, I inferred that a macro is being executed internally within this activity.
Therefore, we have not created a macro here, and there is no actual macro.
If the issue can be reproduced even after deleting all the data in the worksheets, would it be possible for you to share it?
If the issue no longer occurs after the data deletion, it suggests that some piece of data might be the cause, and I believe we would need to proceed in identifying that.
Thank you very much.
I encountered the same error even after deleting the data.
The process flow is as follows, but there are cases where an error occurs in step ①, and there are also cases where step ① completes normally and an error occurs in step ②.
Copy the “Custom Order Detail” sheet to a separate workbook.
Delete the “Custom Order Detail” sheet … ①
Copy the “Restructuring Request” sheet to a separate workbook.
What version of the UiPathTeam.Excel.Activities pack or UiPath Excel Activities pack are you using?
Also, if the issue doesn’t happen every time but sporadically, I think you might try adding a wait of about 5 seconds before each activity to see if it improves the situation.
I am also assembling it in the same way.
The versions are
UiPath.Excel.Activities 3.5.1 and UiPathTeam.Excel.Activities 2.0.1.
It was working until yesterday, but today it gives an error every time I run it.
I ran it on my Assistant, but I couldn’t reproduce the error.
Since the behavior may vary depending on the environment, there might be timing issues. To help isolate the cause, could you try placing a wait activity of about 5 seconds before each activity and check if that improves the situation?
I added a 5-second wait between each activity, but that didn’t resolve the issue. It seems that the deletion of the sheets being processed later couldn’t be performed (when I changed the order of deletion, the later ones could not be deleted), so by separating the Excel Application Scope itself, it became possible to process them.