Application.IsInScope 属性 (Visio)
确定对事件处理程序的调用是否在 EnterScope 事件和范围的 ExitScope 事件之间。 此为只读属性。
语法
表达式。IsInScope (nCmdID)
expression:表示 Application 对象的变量。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
nCmdID | 必需 | Long | 范围 ID。 |
返回值
布尔值
备注
代表范围 ID 的常量以 visCmd 为前缀并由 Visio 类型库声明。 您也可以使用由 BeginUndoScope 方法返回的 ID。
您可以在 CellChanged 事件处理程序中使用此属性来确定单元格更改是否是特定操作的结果。
示例
此示例演示如何使用 IsInScope 属性来确定对处理 CellChanged 事件的过程的调用是否在特定范围内;即是否在该范围的 EnterScope 和 ExitScope 事件之间发生调用。
Private WithEvents vsoApplication As Visio.Application
Private lngScopeID As Long
Public Sub IsInScope_Example()
Dim vsoShape As Visio.Shape
'Set the module-level application variable to
'trap application-level events.
Set vsoApplication = Application
'Begin a scope.
lngScopeID = Application.BeginUndoScope("Draw Shapes")
'Draw three shapes.
Set vsoShape = ActivePage.DrawRectangle(1, 2, 2, 1)
ActivePage.DrawOval 3, 4, 4, 3
ActivePage.DrawLine 4, 5, 5, 4
'Change a cell (to trigger the CellChanged event).
vsoShape.Cells("Width").Formula = 5
'End and commit this scope.
Application.EndUndoScope lngScopeID, True
End Sub
Private Sub vsoApplication_CellChanged(ByVal Cell As IVCell)
'Check to see if this cell change is the result of something
'happening within the scope.
If vsoApplication.IsInScope(lngScopeID) Then
Debug.Print Cell.Name & " changed in scope "; lngScopeID
End If
End Sub
Private Sub vsoApplication_EnterScope(ByVal app As IVApplication, _
ByVal nScopeID As Long, _
ByVal bstrDescription As String)
If vsoApplication.CurrentScope = lngScopeID Then
Debug.Print "Entering my scope " & nScopeID
Else
Debug.Print "Enter Scope " & bstrDescription & "(" & nScopeID & ")"
End If
End Sub
Private Sub vsoApplication_ExitScope(ByVal app As IVApplication, _
ByVal nScopeID As Long, _
ByVal bstrDescription As String, _
ByVal bErrOrCancelled As Boolean)
If vsoApplication.CurrentScope = lngScopeID Then
Debug.Print "Exiting my scope " & nScopeID
Else
Debug.Print "ExitScope " & bstrDescription & "(" & nScopeID & ")"
End If
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。