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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| Public Sub RechRdvOutlook()
Dim olApp As Outlook.Application
Dim DossierOutlook As Outlook.MAPIFolder
Dim RdvOutlook As Outlook.AppointmentItem
Dim ns As NameSpace
Dim Compteur As Single
Dim LigneRdvActif As String
Dim rstListeRdv As dao.Recordset
Dim ResultatRech As Object
Dim ElementTrouve As Boolean
Set olApp = New Outlook.Application
Set ns = olApp.GetNamespace("MAPI")
Set DossierOutlook = ns.GetDefaultFolder(olFolderCalendar)
' Référence à la requête contenant les rdv
Set rstListeRdv = CurrentDb.OpenRecordset("SELECT t_rendezvous.idaction,t_rendezvous.ajoutéàoutlook,T_RendezVous.HoraireDebut, T_RendezVous.NotesAction, T_RendezVous.LieuAction, T_RendezVous.RappelAction, T_RendezVous.MinutesRappel, T_RendezVous.NumAction, T_RendezVous.DuréeAction, [Vendeurs et Intervenants].[Vendeur/Intervenant], RqContacts.Contact " & _
"FROM RqContacts INNER JOIN ([Vendeurs et Intervenants] INNER JOIN T_RendezVous ON [Vendeurs et Intervenants].IdVendeurIntervenant = T_RendezVous.IdIntervenant) ON RqContacts.NumContact = T_RendezVous.NumContact;")
'Si l'évenement n'existe pas dans Outlook il sera créé (plus tard dans le code)
If rstListeRdv.RecordCount = 0 Then
MsgBox "Aucune donnée n'existe pour exportation dans Outlook"
Exit Sub
Else
rstListeRdv.MoveFirst
Do While Not rstListeRdv.EOF
Set ResultatRech = RdvOutlook.Find("[GlobalAppointmentID] = " & rstListeRdv!IdAction & "")
'DoCmd.OpenForm ("dialogbox")
'Forms!dialogbox.Caption = "Synchronisation des évenements avec Outlook"
Debug.Print rstListeRdv!IdAction
If ResultatRech.Count = 0 Then
Debug.Print "Aucun élement trouvé"
ElementTrouve = False
Else
ElementTrouve = True
Debug.Print ResultatRech.Count & " Eléments trouvés."
End If
'Si aucun rdv n'est trouvé:
If Not ElementTrouve Then
'NoResults.Show
Else
Debug.Print "Trouvé " & ResultatRech.Count & " items."
End If
'Else
'GoTo CréationRdv
'End If
rstListeRdv.MoveNext
Loop
CréationRdv:
'Création de l'évenement |
Partager