如下代碼范例演示如何訪問 CubeDefs 和 Dimensions 集合。該范例打印立方中每個維的名稱。該代碼假定在名為 Servername 的 OLAP 服務器上存在名為 Bobs Video Store 的數(shù)據(jù)源。
Dim cat As New ADOMD.Catalog
Dim cdf As ADOMD.CubeDef
Dim I As Integer
cat.ActiveConnection = "Data Source=Servername;" + _
"Initial Catalog=Bobs Video Store;Provider=msolap;"
Set cdf = cat.CubeDefs("Bobs Video Store")
For i = 0 To cdf.Dimensions.Count - 1
Debug.Print cdf.Dimensions(i).Name
Next