VBA to test if a Cube is available before refreshing OLEDB Connection

celias

New Member
Joined
Oct 1, 2015
Messages
37
Hello, beautiful minds!
I have an Excel file that connects to a Cube on a SQL database. I created that connection with Get Data > From Database > From Analysis Services.

The cube I ma connecting to is updated every few hours and while that process is happening, I cannot work on my file.

Is there a way to verify with VBA if the cube is available before proceeding to data refreshing or other procedures within the file? I am pasting the code that I recorded when adding the connection:

Code:
    Application.CutCopyMode = False    With ActiveWorkbook.Connections("cs-sql03 BI ERP test").OLEDBConnection
        .CommandText = Array("ERP")
        .CommandType = xlCmdCube
        .Connection = Array( _
        "OLEDB;Provider=MSOLAP.8;Integrated Security=SSPI;Persist Security Info=True;Data Source=cs-sql03;Update Isolation Level=2;Initial Cata" _
        , "log=BI")
        .RefreshOnFileOpen = False
        .SavePassword = False
        .SourceConnectionFile = _
        "\\cs-dc1\data\users\calves\My Data Sources\cs-sql03 BI ERP vba.odc"
        '.SourceDataFile = ""
        .MaxDrillthroughRecords = 1000
        .ServerCredentialsMethod = xlCredentialsMethodIntegrated
        .AlwaysUseConnectionFile = False
        .RetrieveInOfficeUILang = True
    End With
    With ActiveWorkbook.Connections("cs-sql03 BI ERP test")
        .Name = "cs-sql03 BI ERP test"
        .Description = ""
    End With
    Workbooks("Book1").Connections.AddFromFile _
        "\\cs-dc1\data\users\calves\My Data Sources\cs-sql03 BI ERP vba.odc"

Thank you, in advance, for any guidance you might provide.
Enjoy your day!
Thank you.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top