Private Sub Envoyer_Click()
Dim cel As Range, rng As Range, i As Integer, lig As Integer, Temp
Dim Chaine As String, k As Byte
Dim OlApp As Object, objAppt As Object
Dim namespaceOutlook As Outlook.Namespace
Dim DossierCalendrier As Outlook.MAPIFolder
Application.WindowState = xlMinimized
Me.TNom = UsfData.TextBox1
Me.Hide
With Sheets("Data").Range("a2:o10000")
Set cel = .Find(TNom.Value, , xlValues)
If Not cel Is Nothing Then
TextBox1.Value = cel.Offset(0, 0) & Chr(60) & cel.Offset(0, 3) & Chr(62)
RnName = TextBox1.Value
RnDeb = cel.Offset(0, 14)
RnFin = cel.Offset(0, 11)
cel.Offset(0, 12).Value = ComboBox4.Value
End If
End With
RnSubject = TextBox2
RnBody = TextBox3
RnLocation = ComboBox1
RnCategories = Lbl_Cat.Caption
Chemin = "C:\Windows\Media\Windows Notify Calendar.wav"
With Sheets("Categories").Range("f3:g26")
Set rng = .Find(ComboBox4.Value, , xlValues)
If Not rng Is Nothing Then
Temp = rng.Offset(0, 1) / 60
RnRappel = Temp * 60
End If
With UsfData
For k = 0 To .ListBox1.ListCount - 1
If .CheckBox1 = True Then
Chaine = Chaine & " " & cel.Offset(k, 0) & Chr(60) & .ListBox1.List(k) & Chr(62) & ";"
RnName = Chaine
End If
Next k
End With
On Error Resume Next
Set OlApp = CreateObject("Outlook.Application")
With OlApp
.ActiveWindow.WindowState = olMinimized ' olMinimized = 1 - Normale = 2
Set objAppt = OlApp.CreateItem(1)
Set namespaceOutlook = OlApp.GetNamespace("MAPI")
Set DossierCalendrier = namespaceOutlook.GetDefaultFolder(olFolderCalendar)
Set objAppt = DossierCalendrier.Items.Add
End With
With objAppt
.MeetingStatus = olMeeting
.Subject = RnSubject
.Body = RnBody
.Location = RnLocation
.Start = RnDeb
.Duration = RnFin
.Categories = RnCategories
.ReminderMinutesBeforeStart = RnRappel
.ReminderSet = True
.ReminderPlaySound = True
.ReminderSoundFile = Chemin
.RequiredAttendees = RnName
.Display
'.Save
'.Send
End With
Application.DisplayAlerts = False
Set OlApp = Nothing
Set objAppt = Nothing
End With
End Sub