WebSelectionType 属性 (Excel)QueryTable.WebSelectionType property (Excel)

返回或设置一个值, 该值确定整个网页、网页上的所有表或网页上的特定表是否导入查询表。Returns or sets a value that determines whether an entire webpage, all tables on the webpage, or only specific tables on the webpage are imported into a query table. 读/写**XlWebSelectionType**。Read/write XlWebSelectionType.



_表达式_一个代表查询表对象**** 的变量。expression A variable that represents a QueryTable object.


仅当查询表的**QueryType** 属性设置为xlWebQuery, 并且查询返回 HTML 文档时, 才使用此属性。Use this property only when the query table's QueryType property is set to xlWebQuery, and the query returns an HTML document.

如果此属性的值为xlSpecifiedTables, 则可以使用**WebTables** 属性指定要导入的表。If the value of this property is xlSpecifiedTables, you can use the WebTables property to specify the tables to be imported.

如果使用用户界面导入数据, 则会将来自 web 查询或文本查询的数据作为一个查询表**** 对象导入, 而将所有其他外部数据作为**ListObject** 对象导入。If you import data by using the user interface, data from a web query or a text query is imported as a QueryTable object, while all other external data is imported as a ListObject object.

如果使用对象模型导入数据, 则必须将来自 web 查询或文本查询的数据作为查询表导入****, 而所有其他外部数据均可作为ListObject或查询表导入。 ****If you import data by using the object model, data from a web query or a text query must be imported as a QueryTable, while all other external data can be imported as either a ListObject or a QueryTable.

WebSelectionType 属性仅适用于 QueryTable 对象。The WebSelectionType property applies only to QueryTable objects.


本示例在第一个工作簿中第一个工作表中添加一个新的 web 查询表, 然后从该网页的第一个和第二个表中导入数据。This example adds a new web query table to the first worksheet in the first workbook, and then imports data from the first and second tables on the webpage.

Set shFirstQtr = Workbooks(1).Worksheets(1) 
Set qtQtrResults = shFirstQtr.QueryTables _ 
 .Add(Connection := "URL;https://datasvr/98q1/19980331.htm", _ 
 Destination := shFirstQtr.Cells(1,1)) 
With qtQtrResults 
 .WebFormatting = xlNone 
 .WebSelectionType = xlSpecifiedTables 
 .WebTables = "1,2" 
End With

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.