A Basic Example Using ADOMD
Sub BasicQueryExampleII()
Dim cst As ADOMD.Cellset
Dim cat As ADOMD.Catalog
Dim sMDX As String
Dim ws As Worksheet
On Error GoTo ErrHandler
Set ws = ThisWorkbook.Worksheets(2)
sMDX = "SELECT { [Measures].[Units Shipped], " & _
"[Measures].[Units Ordered] } on columns, " & _
"NON EMPTY [Store].[Store City].members on rows " & _
"from Warehouse"
Set cat = New ADOMD.Catalog
cat.ActiveConnection = "Data Source=localhost;Initial Catalog=FoodMart 2000;Provider=msolap;"
Set cst = New ADOMD.Cellset
cst.Open sMDX, cat.ActiveConnection
cst.Close
ExitPoint:
Set cat = Nothing
Set cst = Nothing
Set ws = Nothing
Exit Sub
ErrHandler:
MsgBox "An error occured - " & Err.Description, vbOKOnly
Resume ExitPoint
End Sub
Related examples in the same category