Share via


Propriété InvisibleApp.CurrentScope (Visio)

Détermine l’ID de la portée à l’origine du déclenchement d’un événement. En lecture seule.

Syntaxe

expression. CurrentScope

Expression Variable qui représente un objet InvisibleApp .

Valeur renvoyée

Entier long

Remarques

Renvoie visScopeIDInvalid (-1) si une portée n’est pas ouverte. L’ID de portée peut être un ID de portée Microsoft Visio interne qui correspond à une commande Visio ou à un ID de portée externe transmis à un client Automation par la méthode BeginUndoScope.

Les destinataires d'un événement considèrent une portée comme ouverte si l'événement EnterScope a été déclenché alors que l'événement ExitScope n'a pas encore été déclenché.

Pour déterminer si le déclenchement de la file d'attente d'événements est lié à une portée particulière interne à l'application ou à une portée ouverte et fermée par un client Automation, utilisez la propriété IsInScope.

Exemple

Cet exemple indique comment utiliser la propriété CurrentScope pour déterminer l'ID de la portée active.

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

Assistance et commentaires

Avez-vous des questions ou des commentaires sur Office VBA ou sur cette documentation ? Consultez la rubrique concernant l’assistance pour Office VBA et l’envoi de commentaires afin d’obtenir des instructions pour recevoir une assistance et envoyer vos commentaires.