Table of contents
TOC
折叠目录
展开目录

OfficeDataSourceObject.ApplyFilter 方法 (办公室)OfficeDataSourceObject.ApplyFilter Method (Office)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

将筛选应用于邮件合并数据源,筛选满足特定条件的指定记录。Applies a filter to a mail merge data source to filter specified records meeting specified criteria.

语法Syntax

表达式ApplyFilterexpression. ApplyFilter

表达式_一个表示OfficeDataSourceObject对象的变量。_expression A variable that represents an OfficeDataSourceObject object.

示例Example

本示例添加一个新的筛选器,该筛选器删除“Region”字段为空的所有记录,然后将筛选应用于活动出版物。This example adds a new filter that removes all records with a blank Region field and then applies the filter to the active publication.

Sub OfficeFilters() 
 Dim appOffice As OfficeDataSourceObject 
 Dim appFilters As ODSOFilters 

 Set appOffice = Application.OfficeDataSourceObject 

 appOffice.Open bstrConnect:="DRIVER=SQL Server;SERVER=ServerName;" & _ 
 "UID=user;PWD=;DATABASE=Northwind", bstrTable:="Employees" 

 Set appFilters = appOffice.Filters 

 MsgBox appOffice.RowCount 

 appFilters.Add Column:="Region", Comparison:=msoFilterComparisonEqual, _ 
 Conjunction:=msoFilterConjunctionAnd, bstrCompareTo:="WA" 
 appOffice.ApplyFilter 

 MsgBox appOffice.RowCount 

End Sub

另请参阅See also

概念Concepts

OfficeDataSourceObject 对象OfficeDataSourceObject Object

其他资源Other resources

OfficeDataSourceObject 对象成员OfficeDataSourceObject Object Members

© 2018 Microsoft