Cannot run the macro: The macro may not be available in this workbook or all macros may be disabled

hi

  1. I have enabled all macro in my Excel.
  2. My Excel workbook ends with “.xls”
  3. Tried running the macro via “Execute Macro” inside an Excel Application scope
  4. Tried running the macro via “Invoke VBA” inside an Excel Application scope

But for both 3) & 4), I get the error message that

“The macro may not be available in this workbook or all macros may be disabled”

1 Like

Hi @Anonymous2

Do you call the Macro name correct?

If it correct, please check Marco in your excel files.
as far as i know, maybe some Marco in your excel file has a problem,
Please try to test it by deleting Marco that you don’t want to execute
and using the Execute Marco activities to run it again.

Hi

Thank you for the reply. The macro names are correct. The macro also work fine when I run them myself on Excel.
The issue is Uipath just can’t run the Macro. I noted that “Execute Macro” works fine with simple macro but not with long, complex macros.

Is there a solution to this? Or is there somethings that I need to avoid in the Macro code?
Thank you.

Hi

I found the solution. We mustn’t re-name the module name in Excel. We need to keep it as Module1, Module2, …

Thanks

1 Like

My solutions was actually that you should not have the same not for the textfile and the macro sub name, for example:

image

1 Like

I have the same problem.

  1. VBA is correct, it can run perfectly in a single Excel file
  2. And the Sub name equal to MacroName
    But it shows the same message:image

Here are my flow and vba, please help! thank you.

Sub Outputfile()

Dim ColumnR As Long
ColumnR = Range(“A1”).End(xlDown).Row
For ColumnR = 2 To ColumnR
If Cells(ColumnR, “R”) <> “” Then
Cells(ColumnR, “R”).Clear
End If
If Cells(ColumnR, “AE”) <> “” Then
Cells(ColumnR, “AE”).Clear
End If
If VBA.Left(Cells(ColumnR, “K”), 1) <> 7 And VBA.Left(Cells(ColumnR, “K”), 1) <> 8 Then
Cells(ColumnR, “Y”).Clear
End If
Next ColumnR

Dim AN As String
AN = ActiveWorkbook.Name

lastrow = ActiveCell.Row
Dim b As Integer
For b = lastrow To 2 Step -1
If Cells(b - 1, “J”) = “31” Or Cells(b - 1, “J”) = “39” Then
Cells(b - 1, “AM”) = Left(AN, 12)
End If

Next b

End Sub