Application.CurrentScope property (Visio)
Determines the ID of the scope that causes an event to fire. Read-only.
Syntax
expression.CurrentScope
expression A variable that represents an Application object.
Return value
Long
Remarks
Returns visScopeIDInvalid (-1) if a scope isn't open. The scope ID could be an internal Microsoft Visio scope ID that corresponds to a Visio command or an external scope ID passed to an Automation client by the BeginUndoScope method.
The recipients of an event consider a scope open if the EnterScope event has fired but the ExitScope event has not fired.
To determine if the event queue firing is related to a particular scope internal to the application or one opened and closed by an Automation client, use the IsInScope property.
Example
This example shows how to use the CurrentScope property to determine the ID of the current scope.
Private WithEvents vsoApplication As Visio.Application
Private lngScopeID As Long
Public Sub ScopeActions()
Dim vsoShape As Visio.Shape
'Set the module level application variable to
'trap Application level events.
Set vsoApplication = Application
'Begin a scope, set the module level variable.
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 (which would trigger a cell changed 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 current 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 strDescription As String, _
ByVal bErrOrCancelled As Boolean)
If vsoApplication.CurrentScope = lngScopeID Then
Debug.Print "Exiting current scope " & nScopeID
Else
Debug.Print "ExitScope " & bstrDescription & "(" & nScopeID & ")"
End If
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기