Share via


Worksheet.QueryTables Property (2007 System)

Gets the QueryTables collection that represents all the query tables on the worksheet.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property QueryTables As QueryTables
'Usage
Dim instance As Worksheet 
Dim value As QueryTables 

value = instance.QueryTables
[BrowsableAttribute(false)]
public QueryTables QueryTables { get; }
[BrowsableAttribute(false)]
public:
property QueryTables^ QueryTables {
    QueryTables^ get ();
}
public function get QueryTables () : QueryTables

Property Value

Type: QueryTables
The QueryTables collection that represents all the query tables on the worksheet.

Examples

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

This example is for a document-level customization.

Private Sub RefreshQueryTables()
    If Me.QueryTables.Count > 0 Then 
        Dim i As Integer 
        For i = 1 To Me.QueryTables.Count
            If Not Me.QueryTables(i).Refresh() Then
                MsgBox("Refresh of query table " & Me.QueryTables(i).Name & _
                    " failed.")
            End If 
        Next i
    Else
        MsgBox("This worksheet contains no query tables.")
    End If 
End Sub
private void RefreshQueryTables()
{
    if (this.QueryTables.Count > 0)
    {
        for (int i = 1; i <= this.QueryTables.Count; i+)
        {
            if (!this.QueryTables[i].Refresh(missing))
            {
                MessageBox.Show("Refresh of query table " +
                    this.QueryTables[i].Name + " failed.");
            }
        }
    }
    else
    {
        MessageBox.Show("This worksheet contains no query tables.");
    }
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace