Tables. Add(Object, Range, Object) Method
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a new query table. Returns a QueryTable object that represents the new query table.
public Microsoft.Office.Interop.Excel.QueryTable Add (object Connection, Microsoft.Office.Interop.Excel.Range Destination, object Sql);
Public Function Add (Connection As Object, Destination As Range, Optional Sql As Object) As QueryTable
Required Object. The data source for the query table. Can be one of the following:A string containing an OLE DB or ODBC connection string. The ODBC connection string has the form "ODBC;<connection string>".A QueryTable object from which the query information is initially copied, including the connection string and the SQL text, but not including the
Destination range. Specifying a QueryTable object causes the
Sql argument to be ignored.An ADO or DAO Recordset object. Data is read from the ADO or DAO recordset. Microsoft Excel retains the recordset until the query table is deleted or the connection is changed. The resulting query table cannot be edited.A Web query. A string in the form "URL;<url>", where "URL;" is required but not localized and the rest of the string is used for the URL of the Web query.Data Finder. A string in the form "FINDER;<data finder file path>" where "FINDER;" is required but not localized. The rest of the string is the path and file name of a Data Finder file (*.dqy or *.iqy). The file is read when the Add method is run; subsequent calls to the Connection property of the query table will return strings beginning with "ODBC;" or "URL;" as appropriate.A text file. A string in the form "TEXT;<text file path and name>", where TEXT is required but not localized.
Required Range. The cell in the upper-left corner of the query table destination range (the range where the resulting query table will be placed). The destination range must be on the worksheet that contains the QueryTables object.
Optional Object. The SQL query string to be run on the ODBC data source. This argument is optional when you're using an ODBC data source You cannot use this argument when a QueryTable object, text file, or ADO or DAO Recordset object is specified as the data source.
A query created by this method isn't run until the Refresh(Object) method is called.