excel - Uipath 错误:“此工作簿中可能没有宏”?
问题描述
我正在尝试使用 UIPath 调用 VBA 活动从 Excel 工作表中检索单元格地址。
我是 VBA 编码的新手。我编写了一个函数来检索单元格地址数组,并且编写了一个子过程来调用该函数。
我正在调用 UIPath 活动中名为“调用 VBA”的子程序。当我运行它时,它说
调用 VBA:无法运行宏“Main”。该工作簿中的宏可能不可
用,或者所有宏都可能被禁用。
这是我在 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 活动中调用 VBA 的方式。
解决方案
当您包含 .xlsx excel 文件而不是 .xls 文件时,它可以工作。这是因为 Uipath 调用 VBA 活动不支持 .xls 文件,因为它是旧版本。
推荐阅读
- java - heroku[web.1]:状态从开始变为崩溃
- sql - 格式化查询以在 Oracle SQL 中显示浮点小数
- javascript - 无法在 Testcafe 错误消息中运行 percy 快照测试:npm ERR!缺少脚本:test:percy
- angular-material - Angular 9 - sidenav 仅占用内容的高度
- c# - 您如何处理错误“读取令牌时意外结束。路径'状态机。<> t__builder'”
- javascript - React Native - 动态状态?或等效的解决方案
- django - Django Python Forms - 提交具有多个表单和表单集的复杂视图
- android - Android - fitSystemWindows 不能与 ViewPager.setAdapter 一起使用
- java - 按降序对 Firebase 数据进行排序
- sql - SQL 中的数据转换:根据列中的值从数据集中删除帐户信息