Uipath错误:“此工作簿中可能无法使用宏”?

时间:2018-07-25 06:12:52

标签: excel vba rpa uipath

我正在尝试使用UIPath调用VBA活动从Excel工作表中检索单元格地址。

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

我正在UIPath活动中名为“调用VBA”的子程序中调用。当我运行它时说

  

调用VBA:无法运行宏“ Main”。宏可能不是
  该工作簿中的可用内容,否则可能会禁用所有宏。

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

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活动中调用VBA的方式。 How I call the VBA macro from UIPath

1 个答案:

答案 0 :(得分:0)

当包含.xlsx excel文件而不是.xls文件时,它可以工作。这是因为Uipath调用VBA活动不支持.xls文件,因为它是较旧的版本。