Export (0) Print
Expand All
Expand Minimize

WorksheetBase.QueryTables Property

Gets the Microsoft.Office.Interop.Excel.QueryTables collection that represents all the query tables on the worksheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public QueryTables QueryTables { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.QueryTables
The Microsoft.Office.Interop.Excel.QueryTables collection that represents all the query tables on the worksheet.

The following code example uses the QueryTables property to refresh the data in every Microsoft.Office.Interop.Excel.QueryTable on the current worksheet.

This example is for a document-level customization.

private void RefreshQueryTables()
{
    if (this.QueryTables.Count > 0)
    {
        for (int i = 1; i <= this.QueryTables.Count; i++)
        {
            if (!this.QueryTables[i].Refresh())
            {
                MessageBox.Show("Refresh of query table " +
                    this.QueryTables[i].Name + " failed.");
            }
        }
    }
    else
    {
        MessageBox.Show("This worksheet contains no query tables.");
    }
}

Show:
© 2014 Microsoft