Visio (的 Application.IsInScope 屬性)
判斷事件處理常式的呼叫是否介於 EnterScope 事件和範圍的 ExitScope 事件之間。 唯讀。
語法
運算式。IsInScope (nCmdID)
expression 代表 Application 物件的變數。
參數
名稱 | 必要/選用 | 資料類型 | 描述 |
---|---|---|---|
nCmdID | 必要 | Long | 範圍識別碼。 |
傳回值
布林值
註解
代表範圍識別碼的常數會以 visCmd 為首碼,且由 Visio 型別程式庫宣告。 您還可以使用 BeginUndoScope 方法所傳回的識別碼。
您可以在 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 支援與意見反應。