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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
| Sub exportation()
Dim dirLocation As String
Dim dirLocation2 As String
Dim Racine As String
Dim iMois As Integer
Dim cRendezvous As New rendezvous
Racine = "S:\Developpement\"
Dim objApplication As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objAppointments As Outlook.MAPIFolder
Dim objAppointment As Outlook.AppointmentItem
Dim myAppointment As Outlook.Items
Dim appointmentIndex As Integer
Dim iCompteur As Integer
Set objApplication = CreateObject("Outlook.Application")
Set objNameSpace = objApplication.GetNamespace("MAPI")
Set objAppointments = objNameSpace.GetDefaultFolder(olFolderCalendar)
Set myAppointment = objNameSpace.GetDefaultFolder(olFolderCalendar).Items
dirLocation = Racine & Environ("username") & "." & Format(Now, "yyyymm") & ".xml"
dirLocation2 = Racine & Environ("username") & "." & Format(Now - (Day(Now) + 1), "yyyymm") & ".xml"
For iMois = 0 To 1
If iMois = 0 Then
Open dirLocation For Output As #1
Else
Open dirLocation2 For Output As #1
End If
Print #1, "<?xml version=" & Chr$(34) & "1.0" & Chr$(34) & " encoding=" & Chr$(34) & "ISO-8859-1" & Chr$(34) & "?>"
Print #1, "<!DOCTYPE donnees SYSTEM " & Chr$(34) & "DTD/donneesXML.dtd" & Chr$(34) & ">"
Info = Split(Environ("username"), ".")
Print #1, "<rendez-vous nom=" & Chr$(34) & Info(1) & Chr$(34) & " prenom=" & Chr$(34) & Info(0) & Chr$(34) & ">"
For appointmentIndex = 1 To objAppointments.Items.Count
Set objAppointment = objAppointments.Items.Item(appointmentIndex)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Mois en cours ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'On cherche quels éléments appartiennent au mois en cours, et lesquelles appartiennent au mois d'avant
If Format(objAppointment.Start, "mm") = Format(Now - iMois * (Day(Now) + 1), "mm") Or Format(objAppointment.End, "mm") = Format(Now - iMois * (Day(Now) + 1), "mm") Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Gestion du cas où une tâche dure plusieurs jours ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Format(objAppointment.Start, "dd") <> Format(objAppointment.End, "dd") Then
'Si la tâche chevauche plusieurs mois
If Format(objAppointment.End, "mm") <> Format(objAppointment.Start, "mm") Then
If Format(objAppointment.Start, "mm") = Format(Now - iMois * (Day(Now) + 1), "mm") Then
iCompteur = 0
While Format(objAppointment.Start + iCompteur, "mm") = Format(Now - iMois * (Day(Now) + 1), "mm")
cRendezvous.objet = objAppointment.Subject
cRendezvous.datedebut = Format(objAppointment.Start, "yyyymm") & Format(objAppointment.Start - iCompteur, "dd")
cRendezvous.heuredebut = "0800"
cRendezvous.heurefin = "1730"
If objAppointment.categories = "" Then
cRendezvous.categorie = "HC"
Else
cRendezvous.categorie = objAppointment.categories
End If
cRendezvous.disponibilite = objAppointment.BusyStatus
If objAppointment.Links.Count <> 0 Then
cRendezvous.typerdv = objAppointment.Links.Item(1)
Else
cRendezvous.typerdv = "HP"
End If
cRendezvous.Ecrire
iCompteur = iCompteur + 1
Wend
ElseIf Format(objAppointment.End, "mm") = Format(Now - iMois * (Day(Now) + 1), "mm") Then
iCompteur = Format(objAppointment.End, "dd")
While iCompteur > 0
cRendezvous.objet = objAppointment.Subject
cRendezvous.datedebut = Format(objAppointment.End, "yyyymm") & Format(objAppointment.End - iCompteur + 1, "dd")
cRendezvous.heuredebut = "0800"
cRendezvous.heurefin = "1730"
If objAppointment.categories = "" Then
cRendezvous.categorie = "HC"
Else
cRendezvous.categorie = objAppointment.categories
End If
cRendezvous.disponibilite = objAppointment.BusyStatus
If objAppointment.Links.Count <> 0 Then
cRendezvous.typerdv = objAppointment.Links.Item(1)
Else
cRendezvous.typerdv = "HP"
End If
cRendezvous.Ecrire
iCompteur = iCompteur - 1
Wend
End If
Else
For iCompteur = 0 To Abs(Format(objAppointment.End, "dd") - Format(objAppointment.Start, "dd"))
If Format(objAppointment.Start + iCompteur, "mm") = Format(Now - iMois * (Day(Now) + 1), "mm") Or Format(objAppointment.End + iCompteur, "mm") = Format(Now - iMois * (Day(Now) + 1), "mm") Then
If iCompteur <> (Format(objAppointment.End, "dd") - Format(objAppointment.Start, "dd")) Or Format(objAppointment.End, "hhmmss") <> "000000" Then
cRendezvous.objet = objAppointment.Subject
cRendezvous.datedebut = Format(objAppointment.Start + iCompteur, "yyyymmdd")
cRendezvous.heuredebut = "0800"
cRendezvous.heurefin = "1730"
If objAppointment.categories = "" Then
cRendezvous.categorie = "HC"
Else
cRendezvous.categorie = objAppointment.categories
End If
cRendezvous.disponibilite = objAppointment.BusyStatus
If objAppointment.Links.Count <> 0 Then
cRendezvous.typerdv = objAppointment.Links.Item(1)
Else
cRendezvous.typerdv = "HP"
End If
cRendezvous.Ecrire
End If
End If
Next
End If
Else
cRendezvous.objet = objAppointment.Subject
cRendezvous.datedebut = Format(objAppointment.Start, "yyyymmdd")
cRendezvous.heuredebut = Format(objAppointment.Start, "hhmm")
cRendezvous.heurefin = Format(objAppointment.End, "hhmm")
If objAppointment.categories = "" Then
cRendezvous.categorie = "HC"
Else
cRendezvous.categorie = objAppointment.categories
End If
cRendezvous.disponibilite = objAppointment.BusyStatus
If objAppointment.Links.Count <> 0 Then
cRendezvous.typerdv = objAppointment.Links.Item(1)
Else
cRendezvous.typerdv = "HP"
End If
cRendezvous.Ecrire
End If
End If
Next
Print #1, "</rendez-vous>"
Close #1
Next
MsgBox "Les sauvegardes on été effectuées dans : " & dirLocation & " et " & dirLocation2
End Sub |
Partager