Uipath error: "macro may not be available in this workbook"?

Uipath error: "macro may not be available in this workbook"?

我正在尝试使用 UIPath 调用 VBA activity.

从 Excel sheet 检索单元格地址

我是 VBA 编码新手。我编写了一个函数来检索单元格地址数组,并且编写了一个子过程来调用该函数。

我在 UIPath activity 中调用名为 'invoke VBA' 的子程序。当我 运行 这个它说

Invoke VBA : Cannot run the macro 'Main'. The macro may not be
available in this workbook or all macros may be disabled.

这是我在 Excel 中启用宏的屏幕截图:

Sub Main(Amount As Integer)
    Call findcellFunction(Amount)
End Sub

Function findcellFunction(Amount As Integer)As Collection
    On Error Resume Next
    Dim rngX As Range           
    Dim WS As Worksheet
    Dim datax As Range
    Dim cellAddress As Variant
    Dim index As Integer
    Dim iTotal As Integer
    Dim CellArray 
    iTotal = 0
    Set CellArray = New Collection
    'Iterate until all cell values are found
    For index=1 To Amount
        Set rngX = Worksheets("rptBOMColorPrint").Range("A1:EZ50").Find("Colour Name", lookat:=xlPart)
        If Not rngX Is Nothing Then
            MsgBox "Found at " & rngX.Address
            CellArray.Add rngX.Address
        End If
        Cells(rngX.Row,rngX.Column).Delete
        iTotel =iTotal + index
    Next index
    'shows list that has been populated with cell addresses
    For Each cellAddress In CellArray
        MsgBox "list populated " & cellAddress
        Range(cellAddress).Value = "Colour Name"
    Next
    CellArray = findcellFunction(Amount)
End Function

这就是我从 UIPath activity 调用 VBA 的方式。

当您包含 .xlsx excel 文件而不是 .xls 文件时,它会起作用。这是因为 Uipath invoke VBA activity 不支持 .xls 文件,因为它是旧版本。