1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Option Explicit
Private Sub Btnvalider_Click()
Dim strChemin As String
Dim strNomFic As String
Dim Lg
Application.ScreenUpdating = False
Application.DisplayAlerts = False
' Si le nom du fichier n'est pas saisi, message alerte et on ne fait rien
strNomFic = TextBox1.Value
If strNomFic = "" Then
MsgBox "Le nom du fichier doit être saisi", vbCritical, "Enregistrement impossible"
Exit Sub
End If
If strChemin = "" Then strChemin = ThisWorkbook.Path
' Copie en Excel
Select Case Sheets("47").Range("M1")
Case "Vente Janvier"
With Sheets("1")
.Visible = xlSheetVisible
.Copy
.Visible = xlSheetHidden
End With
Case Else
MsgBox "Page inexistante"
Exit Sub
End Select
ActiveSheet.SaveAs strChemin & "\" & strNomFic
' Fermer le fichier sauvegardé
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub |
Partager