IsInScope Property [Visio 2003 SDK Documentation]
Determines whether a call to an event handler is between an EnterScope event and an ExitScope event for a scope.
boolVal = object**.IsInScope** (nScopeID)**
boolVal Boolean. True if an EnterScope event has fired for the scope ID, but an ExitScope event hasn't fired yet; False if an EnterScope event hasn't fired or EnterScope and ExitScope events have both fired.
object Required. An expression that returns an Application object.
nScopeID Required Long. The scope ID.
Version added
2000
Remarks
Constants representing scope IDs are prefixed with visCmd and are declared by the Visio type library. You can also use an ID returned by the BeginUndoScope method.
You could use this property in a CellChanged event handler to determine whether a cell change was the result of a particular operation.
Example
This example shows how to use the IsInScope property to determine whether a call to a procedure that handles the CellChanged event is in a particular scope—that is, whether the call occurs between the EnterScope and ExitScope events for that scope.
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
Applies to | Application object | InvisibleApp object
See Also | BeginUndoScope method | CurrentScope property | EndUndoScope method | EnterScope event | ExitScope event