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 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| Private Sub CommandButton1_Click()
Dim sPath As String, sFic As String
Dim ShtS As Worksheet
' On teste la saisie du nom ... If Me.txtNom.Text = "" Then
If Me.txtNoJob.Text = "" Then
MsgBox "Vous devez entrer un No.Job."
Me.txtNoJob.SetFocus
Exit Sub
End If
GoTo Suite
' On teste la saisie du prénom ... If Me.txtPrenom.Text = "" Then
If Me.txtClient.Text = "" Then
MsgBox "Vous devez entrer un nom de client."
Me.txtClient.SetFocus
Exit Sub
End If
If Me.txtModele.Text = "" Then
MsgBox "Vous devez entrer un numéro de modèle."
Me.txtModele.SetFocus
Exit Sub
End If
If Me.txtPrepare.Text = "" Then
MsgBox "Vous devez entrer votre nom."
Me.txtPrepare.SetFocus
Exit Sub
End If
If Me.txtDate.Text = "" Then
MsgBox "Vous devez entrer la date."
Me.txtDate.SetFocus
Exit Sub
End If
Sheets("RAPPORT").Range("D3").Value = Me.txtNoJob.Text
Sheets("RAPPORT").Range("D4").Value = Me.txtClient.Text
Sheets("RAPPORT").Range("D5").Value = Me.txtModele.Text
Sheets("RAPPORT").Range("D6").Value = Me.txtPrepare.Text
Sheets("RAPPORT").Range("I6").Value = Me.txtDate.Text
Suite:
' Définir le chemin d'accès au fichier ainsi que son nom
sPath = ThisWorkbook.Path & "\"
sFic = Me.txtNoJob & ".xlsx"
' Copier la feuille du classeur correspondant
Workbooks.Open sPath & sFic
ActiveWorkbook.Sheets("TABLEMAT").Cells.Copy
ThisWorkbook.Sheets("TABLEMAT").Paste
Application.CutCopyMode = False
ActiveWorkbook.Close
' Fermer l'userform
Unload Me
End Sub |
Partager