我想调用 Microsoft Dynamics NAV Excel 插件的“刷新”功能,该插件在功能区上有一个使用 VBA 宏的按钮。
我尝试在单击按钮时录制宏,但由于“Selection.AutoFilter”行,代码不起作用并引发运行时错误:
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveWorkbook.Names("ConnectionInfo").Delete
ActiveWorkbook.Names.Add Name:="ConnectionInfo", RefersToR1C1:= _
"='Sales Orders'!R1C1:R1C16"
ActiveWorkbook.Names("ObjectInfo").Delete
ActiveWorkbook.Names.Add Name:="ObjectInfo", RefersToR1C1:= _
"='Sales Orders'!R2C1:R2C16"
ActiveWorkbook.Names("ConnectionInfo").Delete
ActiveWorkbook.Names.Add Name:="ConnectionInfo", RefersToR1C1:= _
"='Sales Orders'!R1C1:R1C16"
ActiveWorkbook.Names("ObjectInfo").Delete
ActiveWorkbook.Names.Add Name:="ObjectInfo", RefersToR1C1:= _
"='Sales Orders'!R2C1:R2C16"
With ActiveWorkbook.Worksheets("Sales Orders").ListObjects("NavDataRegion"). _
Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
Selection.AutoFilter
End Sub
宏命名数据中包含连接地址和 NAV 列表名称的范围,但不对它们做任何事情。
它是一个 VSTO COM 加载项,AFAIK 不会出现在VBA 引用、加载项或对象浏览器中。
我运行了这段代码:
Sub comDATA()
Dim oCAI As COMAddIn
For Each oCAI In Application.COMAddIns
Debug.Print oCAI.Description & vbTab & oCAI.progID
Next oCAI
End Sub
并发现 ProgID 是Microsoft.Dynamics.NAV.ExcelAddin,但我不知道刷新按钮的功能名称或如何正确执行它。
任何帮助,将不胜感激。