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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| Private Sub CBEnregistrerDemandeActivite_Click()
Dim oExcel As excel.Application
Dim oWk As Workbook
Dim adresse As String
Dim dest As Range
Dim OutlookApp As New Outlook.Application
Dim NewMail As Outlook.MailItem
If TBdemandeur = "" Or TBFinActivite = "" Or TBImputation = "" Or TBprojet = "" Or TBNbreElement = "" Then
MsgBox "Saisissez tous les champs obligatoire", , "Information"
Label7.Visible = True
Label8.Visible = True
Label9.Visible = True
Label10.Visible = True
Label11.Visible = True
Exit Sub
End If
adresse = "\\MonRepertoire"
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = False 'Masque l'application excel (valeur par défaut)
On Error Resume Next 'Pour éviter les erreur si classeur n'existe pas
Set oWk = oExcel.Workbooks.Open(adresse & "\Info Activités ACTXXXX-XXX.xlsx")
On Error GoTo 0
If oWk Is Nothing Then
MsgBox "Erreur sur ouverture classeur fichier inexistant ", vbCritical
Exit Sub
End If
Set dest = Sheets("feuil1").Cells(Application.Rows.Count, 1).End(xlUp).Offset(1, 0)
dest.Offset(0, 2).Value = TBdemandeur
dest.Offset(0, 4).Value = TBFinActivite
dest.Offset(0, 5).Value = TBImputation
dest.Offset(0, 6).Value = TBprojet
dest.Offset(0, 7).Value = TBCommentaire
dest.Offset(0, 8).Value = TBNbreElement
MsgBox " Merci, Votre demande a été enregistrée et un email a été envoyé au responsable ", , "Demande Effectuée"
Set NewMail = OutlookApp.CreateItem(olMailItem)
NewMail.Recipients.Add ("email.fr")
NewMail.Subject = "Demande Activité"
NewMail.Body = TBdemandeur & " souhaite la prise en charge du projet " & " '' " & TBprojet & " '' " & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & _
"" & TBCommentaire
NewMail.Send
'Sauve le classeur
oWk.Save
oWk.Close False 'Ferme le classeur
oExcel.Quit
Set oWk = Nothing
Set oExcel = Nothing 'libération mémoire..
Unload DemandeActivite
Unload Executable_Technologue_YQMC
End Sub |
Partager