anass1
XLDnaute Junior
Bonjour,
J'ai utilisé ce code pour ouvrir seulement le UserForm et cacher le classeur (Seulement concerné);
SVP, Je veux vérifier ce code. Est-ce efficace ?
Merci.
thisworkbook :
UserForm
Module
classe module
J'ai utilisé ce code pour ouvrir seulement le UserForm et cacher le classeur (Seulement concerné);
SVP, Je veux vérifier ce code. Est-ce efficace ?
Merci.
thisworkbook :
VB:
Private Sub Workbook_Open()
On Error Resume Next
Set AppClass.AppXL = Application
If Application.Workbooks.Count = 1 Then
Application.Visible = False
Else
ThisWorkbook.Windows(1).Visible = False
End If
UserForm1.Show vbModeless
If Err Then ThisWorkbook.Saved = True: If Workbooks.Count = 1 Then Application.Quit Else ThisWorkbook.Close
End Sub
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim FM
If Application.Workbooks.Count = 1 Then
If Application.Visible = False Then
FM = MsgBox(prompt:=" " & vbLf & _
"Voulez-vous réellement fermer ?", Buttons:=vbOKCancel)
If FM = vbOK Then
If Not AppClass Is Nothing Then Set AppClass = Nothing
' ThisWorkbook.Save
Application.Quit
Else
Cancel = True
End If
End If
Else
If Application.Visible = True Then
FM = MsgBox(prompt:=" " & vbLf & _
"Voulez-vous réellement fermer ?", Buttons:=vbOKCancel)
If FM = vbOK Then
If Not AppClass Is Nothing Then Set AppClass = Nothing
' ThisWorkbook.Save
ThisWorkbook.Close
Else
Cancel = True
End If
End If
End If
End Sub
Code:
Option Explicit
Public AppClass As New Classe1
Public UserFormVisible As Boolean
Code:
Option Explicit
Public WithEvents AppXL As Application
Private Sub AppXL_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
If Application.Workbooks.Count = 2 Then
Application.Visible = False
If UserFormVisible = False Then UserForm1.Show vbModeless
Else
ThisWorkbook.Windows(1).Visible = False
End If
End Sub