Option Explicit
Dim obj As Sheets
Dim Valeur As String
Private Sub Recherche_OK_Click()
On Error GoTo Gerreur
Début:
If ComboBox1 = "" Then
MsgBox "Faites votre choix !", vbExclamation
ComboBox1.SetFocus
Exit Sub
End If
MsgBox " Êtes-vous sûr de vouloir archiver " & ComboBox1 & " ?", vbCritical + vbYesNoCancel + 256, "Attention"
If vbYes Then
Dim lerep
lerep = ActiveWorkbook.Path
With Application.FileSearch
.NewSearch
.LookIn = lerep
.Filename = ComboBox1 & ".xls"
.MatchTextExactly = True
.Execute
End With
Sheets(ComboBox1.Text).Move After:=Workbooks("archive.xls").Sheets(3)
For Each obj In ActiveSheet.Shapes
obj.Delete
Next
ActiveWorkbook.Save
ActiveSheet.name = Valeur
ActiveWorkbook.Close (True)
End If
If vbNo Then
Unload Me
Else
ComboBox1.SetFocus
End If
Exit Sub
Gerreur:
If Err.Number = 9 Then
Beep
MsgBox "Attention !" & ComboBox1.Text & " n'existe pas!"
ComboBox1.SetFocus
End If
End Sub