您好,有人建议我尝试学习办公脚本,并尝试将现有的基于 vba 的解决方案转换为办公脚本。现有解决方案编写 DAX 查询并返回 Excel 表。我在打字稿中找不到如何访问它。
VBA 是
Function GetDataFromDataModel(myDAXScript As String) As ListObject
Dim myDaxHubTable As ListObject
Set myDaxHubTable = blwModel.ListObjects("dxtDAXHub")
With myDaxHubTable.TableObject.WorkbookConnection.OLEDBConnection
.CommandText = myDAXScript
.CommandType = xlCmdDAX
End With
'Debug.Print myDAXScript
ActiveWorkbook.Connections(myDaxHubTable.TableObject.WorkbookConnection.Name).Refresh
Set GetDataFromDataModel = myDaxHubTable
End Function