QueryTable Property

Microsoft Excel Visual Basic

ShowQueryTable property as it applies to the ListObject object.

Returns the QueryTable object that provides a link for the ListObject object to the list server. Read-only.

ShowQueryTable property as it applies to the Range object.

Returns a QueryTable object that represents the query table that intersects the specified Range object. Read-only.

Example

This example refreshes the QueryTable object that intersects cell A10 on worksheet one.

Worksheets(1).Range("a10").QueryTable.Refresh
		

The following example creates a connection to a SharePoint site and publishes the ListObject object named List1 to the server. A reference to the QueryTable object for the list object is created and the MaintainConnection property of the QueryTable object is set to True so that the connection to the SharePoint site is maintained between trips to the server.

   
   Dim wrksht As Worksheet
   Dim objListObj As ListObject
   Dim objQryTbl As QueryTable
   Dim prpQryProp As pro
   Dim arTarget(4) As String
   Dim strSTSConnection As String
   
   Set wrksht = ActiveWorkbook.Worksheets("Sheet1")
   Set objListObj = wrksht.ListObjects(1)
   
   arTarget(0) = "0"
   arTarget(1) = "http://myteam/project1"
   arTarget(2) = "1"
   arTarget(3) = "List1"
   
   strSTSConnection = objListObj.Publish(arTarget, True)
   
   Set objQryTbl = objListObj.QueryTable
   
   objQryTbl.MaintainConnection = True