'-------------------------------------
'Mode d'affichage du UserForm
'
'- Obj est soit un Control du UserForm
' soit un UserForm
'
'- Return: vbModal (1)
' vbModeless (0)
' Erreur (-1)
'-------------------------------------
Function UserFormShowMode(ByVal Obj As Object) As Integer
On Error Resume Next
'Cherche l'objet au sommet de la hiérarchie
Do While Err.Number = 0
Set Obj =...
Private Sub CommandButton1_Click()
MsgBox UserFormShowMode(Frame2)
MsgBox UserFormShowMode(Frame1)
MsgBox UserFormShowMode(Me)
End Sub
Dis-le clairement au lieu de jouer au plus malin !a ben ouii je met des controls et oui un multipage
Sub testNonModal()
TOTOUSF.Show 0
End Sub
Sub testModal()
TOTOUSF.Show
End Sub
Sub test_avec_un_control_du_userform() 'le meme test est efectué au click sur le bouton dans le userform en modal
MsgBox UserFormShowMode(UserForm1.CommandButton1)
End Sub
Function UserFormShowMode(ByVal Obj As Object) As Integer
Dim errNum&, I&, previousOBJ As Object
'Init Return Value
Do While errNum = 0
On Error Resume Next
Set previousOBJ = Obj: Set Obj = Obj.Parent
errNum = Err.Number
Debug.Print "previous object " & previousOBJ.Name & " - object parent " & Obj.Name & " error : " & Err.Number
Err.Clear
Loop
MsgBox TypeOf previousOBJ Is UserForm
MsgBox TypeOf Obj Is UserForm
End Function
Sub testNonModal()
TOTOUSF.Show 0
End Sub
Sub testModal()
TOTOUSF.Show
End Sub
Sub test_avec_un_control_du_userform() 'le meme test est efectué au click sur le bouton dans le userform en modal
MsgBox UserFormShowMode(UserForm1.CommandButton1)
End Sub
Function UserFormShowMode(ByVal Obj As Object) As Integer
Dim errNum&, I&, previousOBJ
Do While errNum = 0
On Error Resume Next
Set previousOBJ = Obj: Set Obj = Obj.Parent
errNum = Err.Number
Debug.Print "previous object " & previousOBJ.Name & " - object parent " & Obj.Name & " error : " & Err.Number
If Err.Number > 0 Then Set Obj = previousOBJ: Err.Clear: Exit Do
Err.Clear
Loop
Obj.Show 0 'on tente le show vbmodeless
If Err.Number = 0 Then UserFormShowMode = 0 Else UserFormShowMode = 1
On Error GoTo 0
End Function