IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Outlook Discussion :

Compter rendez-vous / reunion selon categorie


Sujet :

VBA Outlook

  1. #1
    Membre à l'essai
    Homme Profil pro
    Informaticien autodidacte
    Inscrit en
    Août 2015
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Informaticien autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2015
    Messages : 31
    Points : 18
    Points
    18
    Par défaut Compter rendez-vous / reunion selon categorie
    Bonjour,

    Je souhaite compter les réunions / rendez-vous comportant une catégorie précise mais mes recherches sur le net n'ont pas donné grand-chose, à part ce code qui n'a pas d'erreur mais ne renvoie rien :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    Sub FindAppts()
    Dim myStart As Date
    Dim myEnd As Date
    Dim oCalendar As Outlook.Folder
    Dim oItems As Outlook.Items
    Dim oItemsInDateRange As Outlook.Items
    Dim oFinalItems As Outlook.Items
    Dim oAppt As Outlook.AppointmentItem
    Dim strRestriction As String
     
    myStart = Format(Date, "dd/mm/yyyy")
    myEnd = DateAdd("d", 30, myStart)
     
    Debug.Print "Start:", myStart
    Debug.Print "End:", myEnd
     
    'Construct filter for the next 30-day date range
    strRestriction = "[Start] >= '" & myStart & "' AND [End] <= '" & myEnd & "'"
    'Check the restriction string
    Debug.Print strRestriction
    Set oCalendar = Application.Session.GetDefaultFolder(olFolderCalendar)
    Set oItems = oCalendar.Items
    oItems.IncludeRecurrences = True
    oItems.Sort "[Start]"
    'Restrict the Items collection for the 30-day date range
    Set oItemsInDateRange = oItems.Restrict(strRestriction)
    'Construct filter for Subject containing 'team'
    Const PropTag  As String = "http://schemas.microsoft.com/mapi/proptag/"
    strRestriction = "@SQL=" & Chr(34) & PropTag _
        & "0x0037001E" & Chr(34) & " like '%Congé%'"
    'Restrict the last set of filtered items for the subject
    Set oFinalItems = oItemsInDateRange.Restrict(strRestriction)
    'Sort and Debug.Print final results
    oFinalItems.Sort "[Start]"
    For Each oAppt In oFinalItems
        Debug.Print oAppt.Start, oAppt.Subject
    Next
    End Sub
    Le code d'origine prenait des dates au format anglo-saxon, donc j'ai modifié le format de date au format français... mais pas mieux !
    Donc si quelqu'un a une vague idée d'un semblant de début de piste, je suis preneur !!!

    Bon week-end printanier !

    ThierryP

  2. #2
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    Bonjour,
    Essaye comme cela
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Sub FindAppts()
        Dim myStart As Date
        Dim myEnd As Date
        Dim oCalendar As Outlook.Folder
        Dim oItems As Outlook.Items
        Dim oItemsInDateRange As Outlook.Items
        Dim oFinalItems As Outlook.Items
        Dim oAppt As Outlook.AppointmentItem
        Dim strRestriction As String
     
        Dim OL As Object
        If UCase(Application) = "OUTLOOK" Then
            Set OL = Application
        Else
            Set OL = CreateObject("outlook.application")
        End If
     
     
        myStart = Format(Date, "dd/mm/yyyy")
        myEnd = DateAdd("d", 30, myStart)
     
        Debug.Print "Start:", myStart
        Debug.Print "End:", myEnd
     
        'Construct filter for the next 30-day date range
        strRestriction = "[Start] >= '" & myStart & "' AND [End] <= '" & myEnd & "'"
        'Check the restriction string
        Debug.Print strRestriction
        Set oCalendar = OL.Session.GetDefaultFolder(olFolderCalendar)
        Set oItems = oCalendar.Items
        oItems.IncludeRecurrences = False
        oItems.Sort "[Start]"
        'Restrict the Items collection for the 30-day date range
        Set oItemsInDateRange = oItems.Restrict(strRestriction)
     
        'Construct filter for Subject containing 'team'
        Const PropTag As String = "http://schemas.microsoft.com/mapi/proptag/"
        ' 0x8021101E
     
    ' les 3 écritures ci-dessous fonctionnent
        'strRestriction = "[Catégories] = 'Congé (Jour de)'" ' nom exact de la catégorie
        'strRestriction = "@SQL=" & Chr(34) & "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Keywords" & Chr(34) & " like 'Congé (Jour de)'"
        strRestriction = "@SQL=" & Chr(34) & "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Keywords" & Chr(34) & " like '%Congé%'"
     
     
        'Restrict the last set of filtered items for the subject
        Debug.Print strRestriction
        Set oFinalItems = oItemsInDateRange.Restrict(strRestriction)
        'Sort and Debug.Print final results
        oFinalItems.Sort "[Start]"
        MsgBox oFinalItems.Count
        For Each oAppt In oFinalItems
            Debug.Print oAppt.Start, oAppt.Subject
        Next
    End Sub

  3. #3
    Membre à l'essai
    Homme Profil pro
    Informaticien autodidacte
    Inscrit en
    Août 2015
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Informaticien autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2015
    Messages : 31
    Points : 18
    Points
    18
    Par défaut
    Bonjour Oliv'

    Ton code fonctionne, c'est parfait je vais pouvoir broder là autour !!!
    Juste une 'tite question : où as-tu trouvé la syntaxe pour construire les filtres ?

    Encore merci,

    ThierryP

  4. #4
    Expert éminent
    Avatar de Oliv-
    Homme Profil pro
    solution provider
    Inscrit en
    Mars 2006
    Messages
    4 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : solution provider

    Informations forums :
    Inscription : Mars 2006
    Messages : 4 087
    Points : 7 168
    Points
    7 168
    Billets dans le blog
    20
    Par défaut
    d'une part il y a l'aide et aussi j'utilise MFCMAPI qui permet de trouver les propriétés.

Discussions similaires

  1. Réponses: 2
    Dernier message: 26/01/2016, 22h07
  2. [MySQL] Calendrier avec gestion de rendez vous
    Par t-die dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 19/07/2012, 20h35
  3. Compter les rendez-vous de plusieurs calendriers
    Par Sitting Bull dans le forum VBA Outlook
    Réponses: 0
    Dernier message: 06/09/2010, 21h55
  4. Rendez-vous Outlook depuis Access
    Par pascal@falcy.ch dans le forum Access
    Réponses: 4
    Dernier message: 03/10/2005, 21h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo