DataRecordset.GetMatchingRowsForRefreshConflict 方法 (Visio)
返回由链接到形状的数据记录集行(数据记录集刷新后存在冲突)的行 ID 组成的数组。
注意
此 Visio 对象或成员仅供 Visio Professional 2013 的授权用户使用。
语法
表达式。GetMatchingRowsForRefreshConflict (ShapeInConflict)
表达 返回 DataRecordset 对象的表达式。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
ShapeInConflict | 必需 | Shape | 链接到数据的形状,该数据在刷新数据记录集后发生冲突。 |
返回值
Long ()
备注
GetAllRefreshConflicts 方法返回形状数组,其中形状中的数据与形状链接到的数据记录集行中的数据之间存在冲突。 若要确定哪些数据记录集行产生了冲突,可以依次将这些形状中的每一个传递给 GetMatchingRowsForRefreshConflict 方法,该方法返回给定形状冲突的行数组。
当数据记录集中的两个或更多个行具有相同主关键字并且可能链接到同一个形状时,这些行可能存在冲突。 出现这种情况时,GetMatchingRowsForRefreshConflict 将返回至少包含两个行 ID 的数组。
在从数据记录集中删除以前的数据链接行时,也可能发生冲突。 出现这种情况时,该方法将返回空数组。
若要删除冲突,请将具有冲突的形状传递给 RemoveRefreshConflict 方法,该方法从当前文档中删除冲突信息。 有关冲突的信息将保留在当前文档中,直到您删除存在冲突的形状或对该形状调用 RemoveRefreshConflict 为止。
示例
此 Microsoft Visual Basic for Applications (VBA) 宏演示如何使用 GetAllRefreshConflicts 方法来确定在刷新数据记录集后哪些形状(如果有)存在冲突,然后使用 GetMatchingRowsForRefreshConflict 方法确定哪些数据记录集行引起冲突。 该方法将刷新最近添加的数据记录集,如果发现未产生任何冲突,则在“立即”窗口中输出“无冲突”。 如果的确发现冲突,该方法就会将存在冲突的每个形状传递给 GetMatchingRowsForRefreshConflict 方法,并在同一窗口中输出产生的行 ID。
在运行此宏之前,请确保最近添加的数据记录集是已连接(不基于 XML)的数据记录集,并且到原始数据源的连接仍然可用。 然后在数据源中删除行或进行其他可在刷新数据记录集时引起冲突的更改。
Public Sub GetMatchingRowsForRefreshConflict_Example()
Dim vsoDataRecordset As Visio.DataRecordset
Dim intRecordsetCount As Integer
Dim intShapeCount As Integer
Dim vsoShapes() As Visio.Shape
Dim intRowCount As Integer
Dim vsoShapeInConflict As Visio.Shape
Dim alngRowIDs() As Long
Dim lngvsoRowID As Long
intRecordsetCount = Visio.ActiveDocument.DataRecordsets.Count
Set vsoDataRecordset = Visio.ActiveDocument.DataRecordsets(intRecordsetCount)
vsoDataRecordset.Refresh
vsoShapes = vsoDataRecordset.GetAllRefreshConflicts
If IsEmpty(vsoShapes) Then
Debug.Print "No conflict"
Else
For intShapeCount = LBound(vsoShapes) To UBound(vsoShapes)
Set vsoShapeInConflict = vsoShapes(intShapeCount)
alngRowIDs = vsoDataRecordset.GetMatchingRowsForRefreshConflict(vsoShapeInConflict)
If IsEmpty(alngRowIDs) Then
Debug.Print "For shape:", vsoShapeInConflict.Name, "Row deleted."
Else
For intRowCount = LBound(alngRowIDs) To UBound(alngRowIDs)
lngvsoRowID = alngRowIDs(intRowCount)
Debug.Print "For shape:", vsoShapeInConflict.Name, "Row ID of row in conflict:", lngvsoRowID
Next intRowCount
End If
Next intShapeCount
End If
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。