Propriété InvisibleApp.IsInScope (Visio)

Détermine si un appel à un gestionnaire d’événements se situe entre un événement EnterScope et un événement ExitScope pour une étendue. En lecture seule.

Syntaxe

expression. IsInScope (nCmdID)

Expression Variable qui représente un objet InvisibleApp .

Parameters

Nom Requis/Facultatif Type de données Description
nCmdID Obligatoire Long ID de portée.

Valeur renvoyée

Booléen

Remarques

Les constantes représentant les ID de portée ont pour préfixe visCmd et sont déclarées par la bibliothèque de types de Visio. Vous pouvez également utiliser un ID renvoyé par la méthode BeginUndoScope.

Vous pouvez utiliser cette propriété dans un gestionnaire d'événement CellChanged pour déterminer si un changement de cellule résulte d'une opération particulière.

Exemple

Cet exemple montre comment utiliser la propriété IsInScope pour déterminer si un appel à une procédure qui gère l’événement CellChanged se trouve dans une étendue particulière . autrement dit, si l’appel se produit entre les événements EnterScope et ExitScope pour cette étendue.

 
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

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.