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


New Member
Oct 1, 2015
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:

    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.

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...