我覺得像下面這樣:
strConn = _
"Provider=MSOLAP.6;" & _
"Data Source=imxxxxxx;" & _ '<<<name of your server here
"Initial Catalog=AdventureWorksDW2012Multidimensional-EE;" & _ '<<<name of your Adv Wrks db here
"Integrated Security=SSPI"
下面是使用它針對一些mdx
的例子:
Dim pubConn As ADODB.Connection
Set pubConn = New ADODB.Connection
pubConn.CommandTimeout = 0
pubConn.Open strConn
Dim cs As ADOMD.Cellset
Set cs = New ADOMD.Cellset
Dim myMdx As String
myMdx = _
" SELECT" & _
" NON EMPTY" & _
" [Customer].[Customer Geography].[State-Province].&[AB]&[CA] ON 0," & _
" NON EMPTY" & _
" [Measures].[Internet Sales Amount] ON 1" & _
" FROM [Adventure Works];"
cs.Open myMdx, pubConn
以上是從我的回答(在VBA)位置:VBA Reptitive MDX query to Analysis Services
這個有用嗎? http://stackoverflow.com/questions/11188747/any-mdx-query-within-excel-vba – dsolimano
它只是使用不同的提供商,所以我不明白爲什麼不,只需調整連接字符串,然後離開你。 – Lankymart
絕對有用。我對VBScript很滿意,因此它給了我很多自由來獲取我需要的信息。目前,它需要通過各種Excel電子表格進行相當數量的工作。 – user3017424