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 :

macro Prise rdv outlook depuis outlook + export calendrier outlook vers excel


Sujet :

VBA Outlook

  1. #1
    En attente de confirmation mail
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2012
    Messages : 1
    Points : 2
    Points
    2
    Par défaut macro Prise rdv outlook depuis outlook + export calendrier outlook vers excel
    Bonjour à tous,

    J'ai grand besoin de votre aide!

    Voilà, dans mon job actuel d'accueil, j'ai un fichier excel sur lequel j'enregistre tous les jours des entretiens de recrutement.

    Les consultants m'envoient des mails (boite de reception outlook) pour faire des reservations de salles concernant des entretiens.



    Un candidat arrive pour rencontrer un consultant dans une salle.

    2 choses que je n'arrive pas à faire et qui m'aideraient énormément:

    1) Exporter les rdv du calendrier outlook depuis les dossiers publics vers excel

    Je souhaiterais exporter les rdv du jour de outlook vers excel sous forme de liste.
    Ces rdv sont enregistrés non pas sur le calendrier "principal" mais sur d'autres calendriers qui sont des dossiers publics.
    Ainsi je pourrais avoir une liste des rdv du jour avec l'orthographe précise des candidats qui arrivent, l'heure prévue de l'entretien etc...



    2) Prendre les rdv directement sur outlook

    Je reçois parfois entre 30 ou 40 mails.
    L'enjeu ici est de récupérer les infos contenues dans le corps du mail, et de s'en servir pour faire une prise de rdv. (prendre un rdv sur outlook). Je le fais manuellement pour l'instant, mais c'est vraiment débile...

    Voici un exemple de mail que je reçois. Les infos à récupérer sont toujours structurées de la même façon.

    La date et l'heure du rdv sont à la 5è ligne, mais il faut extraire le tout pour qu'excel comprenne le format.
    Il faut aussi extraire

    10225273 / NOM Prénom
    Doc : Oui
    Cons : ABCD
    Consultant : PrénomConsultant NomConsultant
    Date et heure : le mercredi 3 octobre 2012 à 16h00
    Site : Charenton
    Visio : Non
    Candidat lourd : Non

    J'ai mis un bouton dans la barre outlook pour executer la macro apres avoir selectionné un mail de reservation.
    La structure du corps du mail est toujours la meme. Il faut utiliser je pense les fonctions de manipulation de chaînes de caractère.



    Problème:ça ne marche pas. "Erreur 5 appel de procédure ou argument incorrect"


    Voici le début de code que j'ai:
    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
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    Sub ReplyWithMeetingRequest()
     
    On Error GoTo ErrorHandler
     
    Dim obj As Object
    Dim msg As Outlook.MailItem
    Dim meeting As Outlook.AppointmentItem
    Dim i As Long
     
     
     
    ' get currently selected item
    Set obj = ActiveExplorer.Selection.Item(1)
     
     
    ' is it a mail item?
    If TypeName(obj) = "MailItem" Then
      Set msg = obj
      Set meeting = Application.CreateItem(olAppointmentItem)
     
     
     
     
     
     
     
      With meeting
        ' it's a meeting
        .MeetingStatus = olMeeting
        ' same subject as the message
        'subject is the body of the message
        .Subject = msg.Body
        .Duration = 60
        .Body = msg.Body
     
     
     
     
    Dim LongueurMsg As String
    Dim ch1 As String
    Dim extraitInfos As String
     
    LongueurMsg = Len(msg.Body) 
    ch1 = Mid(msg.Body, InStr(msg.Body, "heure : le ") + 10, LongueurMsg) 
    extraitInfos = Left(ch1, InStr(ch1, "site") - 4) 
     
     
     
        ' invite message recipients
        For i = 1 To msg.Recipients.Count
          .Recipients.Add msg.Recipients(i)
        Next i
     
        'invite sender
        .Recipients.Add msg.SenderName
        ' show meeting to set other details
        .Display
      End With
     
    End If
     
    ProgramExit:
      Exit Sub
    ErrorHandler:
      MsgBox Err.Number & " - " & Err.Description
      Resume ProgramExit
    End Sub

  2. #2
    Membre habitué
    Homme Profil pro
    Back Office Marchés
    Inscrit en
    Mars 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Back Office Marchés
    Secteur : Finance

    Informations forums :
    Inscription : Mars 2011
    Messages : 65
    Points : 139
    Points
    139
    Par défaut
    Citation Envoyé par Wavy84 Voir le message
    1) Exporter les rdv du calendrier outlook depuis les dossiers publics vers excel

    Je souhaiterais exporter les rdv du jour de outlook vers excel sous forme de liste.
    Ces rdv sont enregistrés non pas sur le calendrier "principal" mais sur d'autres calendriers qui sont des dossiers publics.
    Ainsi je pourrais avoir une liste des rdv du jour avec l'orthographe précise des candidats qui arrivent, l'heure prévue de l'entretien etc...
    Essaye le code suivant depuis ton classeur de macro perso excel après avoir activé les références Outlook :

    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
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    Sub DLRendezVousOutlookDansExcel()
    Dim MyOlSession As New Outlook.Application
    Dim MyNS As Outlook.Namespace
    Dim MyFolder As Outlook.MAPIFolder
    Dim olRendezVous As Outlook.AppointmentItem
     
    Dim wbClasseur As Workbook
    Dim wsFeuille As Worksheet
    Dim rgPlage As Range, rgEntete As Range
     
    Dim i As Long, TabEntete() As Variant
     
    On Error GoTo Erreur
        Application.ScreenUpdating = False
    TabEntete = Array("Date & Heure début", "Objet", "Message")
     
    Set wbClasseur = Workbooks.Add
        Set wsFeuille = wbClasseur.Sheets(1)
            Set rgEntete = wsFeuille.Range(Cells(1, 1), Cells(1, UBound(TabEntete)))
                rgEntete.Value = TabEntete
        'récup des objets appointment dans Calendar
        Set MyNS = MyOlSession.GetNamespace("MAPI")
            Set MyFolder = MyNS.GetDefaultFolder(olPublicFoldersAllPublicFolders)
                 'chercher le bon répertoire : code à adapter
                 Set MyFolder = MyFolder.Folders("Nom du sous répertoire public où se trouve ton calendrier")
     
            For i = 1 To MyFolder.Items.Count
                Set olRendezVous = MyFolder.Items(i)
                        Cells(i + 1, 1).Value = olRendezVous.Start 'début de la réunion
                    Cells(i + 1, 2).Value = olRendezVous.Subject 'Objet
                Cells(i + 1, 3).Value = olRendezVous.Body 'corps du message éventuel
            Next i
     
        Set rgPlage = wsFeuille.UsedRange
        'tri chronologique & mise en forme
            With rgPlage
                .Sort Range("A1"), xlAscending, , , , , , xlGuess
                .HorizontalAlignment = xlGeneral
                .VerticalAlignment = xlGeneral
                .WrapText = False
            End With
     
        Columns("A:C").EntireColumn.AutoFit
     
    ' désinstanciation
    Set MyNS = Nothing
        Set MyFolder = Nothing
            Set olRendezVous = Nothing
                Set rgPlage = Nothing
            Set rgEntete = Nothing
        Set wsFeuille = Nothing
    Set wbClasseur = Nothing
     
    Application.ScreenUpdating = True
    Exit Sub
     
    'Gestionnaire d'erreur
    Erreur:
        MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
            Set MyNS = Nothing
                Set MyFolder = Nothing
                    Set olRendezVous = Nothing
                    Set rgEntete = Nothing
                Set rgPlage = Nothing
            Set wsFeuille = Nothing
        Set wbClasseur = Nothing
    Application.ScreenUpdating = True
     
    End Sub
    Tu peux rajouter évidemment des éléments dans ton tableau en récupérant la fin, la durée, la sensibilité, les participants etc... Dans ce cas tu ajoutes les entêtes dans le tableau TabEntete() et tu adaptes la boucle des lignes 15-20.

    Tu peux également limiter la recherche aux éléments futurs en rajoutant une condition

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    If olRendezVous.Start > Now Then
        Cells(i + 1, 1).Value = olRendezVous.Start 
        etc...
    End If
    Petite question aux lecteurs du forum : Mon code est assez lent quand il récupère la totalité des éléments à cause de la boucle. J'ai essayé de passer par une variable tableau en bouclant avec un Redim Preserve, mais j'ai un message de type "indice out of range". Est ce que quelqu'un aurait une idée pour optimiser ?

    Cordialement,

    Guillaume

  3. #3
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour à tous,

    Je suis nouveau sur le forum que je parcours régulièrement, je fais quelques macros pour mon travail et je recherche régulièrement des bouts de code pour les assembler et j’arrive relativement bien à m’en sortir,
    Sauf que là cela fait une semaine que je cherche à récupère sur excel toutes les réunions d’un calendrier partagé voir l’image ci-dessous « planning technique »,
    j’ai trouvé un code qui m’exporte sur excel mon calendrier personnel mais je n’arrive pas à exporte les autres calendriers.

    Votre code me donnait espoir mais je bloque sur la ligne

    c’est mon premier message et j’espère vous pourrez m’aider,

    merci d’avance


    j'ai testé la macro et je bloque sur la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Set MyFolder = MyNS.GetDefaultFolder(olPublicFoldersAllPublicFolders)
    il ne trouve pas le calendrier "Planning Technique" qui se trouve dans "Tous les calendriers de groupe"
    Nom : Planning technique.png
Affichages : 978
Taille : 26,8 Ko
    comment je fait pour y acceder ?

    cordialement

  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
    Bonjour,
    Il y a plusieurs façons d'atteindre un calendrier partagé

    voic l'une d'elle

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Set myNameSpace = Application.GetNamespace("MAPI")
        Set myRecipient = myNameSpace.CreateRecipient("NOMDEBOITE")
        myRecipient.Resolve
        If myRecipient.Resolved Then
     
            Set CalendarFolder = _
            myNameSpace.GetSharedDefaultFolder _
                                 (myRecipient, olFolderCalendar)
    '...
    END IF

  5. #5
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour,


    merci pour votre rapide réponse,

    j'ai effectivement testé avec succes d'atteindre un fichier partagé en utilisant cette methode ci dessous,

    sauf que dans le groupe "tous les calendriers de groupe" cela ne fonctionne pas,
    pour le groupe en vert c'est ok pour le groupe en rouge ca marche pas,
    lorsque je pointe sur le calendrier en rouge il m'affiche bien le nom du calendrier et mon adresse mail => Planning Technique - jxxxx.pxxxxxxxx@XXXXX.info

    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
    Sub ResolveName()
        Dim myOlApp As Outlook.Application
        Dim myNamespace As Outlook.Namespace
        Dim myRecipient As Outlook.Recipient
        Dim CalendarFolder As Outlook.MAPIFolder
        Set myOlApp = CreateObject("Outlook.Application")
        Set myNamespace = myOlApp.GetNamespace("MAPI")
        Set myRecipient = myNamespace.CreateRecipient("xxxx.xxxxxx@xxxxx.XXXXXX.xxfo")
        myRecipient.Resolve
        If myRecipient.Resolved Then
            Call ShowCalendar(myNamespace, myRecipient)
        End If
    End Sub
     
    Sub ShowCalendar(myNamespace, myRecipient)
        Dim CalendarFolder As MAPIFolder
        Set CalendarFolder = _
            myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
        CalendarFolder.Display
    End Sub

    Nom : Planning technique.png
Affichages : 978
Taille : 30,3 Ko

    cordialement

  6. #6
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour à tous,

    Avec votre aide j'ai réussi à afficher le calendrier avec lequel j'avais un problème.

    Maintenant je voudrais aller plus loin et exporter sur Excel, pour faire cela j'ai un code qui m'extrait mon calendrier personnel.


    Pouvez-vous m'aider à le modifier afin que j'extrait le calendrier que me partage le planning ?

    Comment fusionner ces 2 programmes ?

    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
    Sub ResolveName()
        Dim myOlApp As Outlook.Application
        Dim myNamespace As Outlook.Namespace
        Dim myRecipient As Outlook.Recipient
        Dim CalendarFolder As Outlook.MAPIFolder
        Set myOlApp = CreateObject("Outlook.Application")
        Set myNamespace = myOlApp.GetNamespace("MAPI")
        Set myRecipient = myNamespace.CreateRecipient("planning technique - <a href="mailto:blablabla@blabal.com">blablabla@blabal.com</a>") 'ou l'adresse lail complette
        myRecipient.Resolve
        If myRecipient.Resolved Then
            Call ShowCalendar(myNamespace, myRecipient)
        End If
    End Sub
     
    Sub ShowCalendar(myNamespace, myRecipient)
        Dim CalendarFolder As MAPIFolder
        Set CalendarFolder = _
            myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
        CalendarFolder.Display
    End Sub
    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
    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
    Sub Appointments()
     
    'c'est la derniere version qui fonctionne avec toutes les données pour toutes les dates
    Application.ScreenUpdating = False
        Sheets("Feuil1").Select
        Range("A1").Select
    Range("C2:I1000").Select
    Selection.ClearContents
    'Application.ScreenUpdating = False
    Call GetCalData(DateTime.Date - 8, DateTime.Date + 60)
        Sheets("Feuil3").Select
        Range("A1").Select
    Application.ScreenUpdating = True
    End Sub
     
    Private Sub GetCalData(StartDate As Date, Optional EndDate As Date)
     
    Dim OlApp As Outlook.Application 'oui
    Dim olNS As Outlook.Namespace 'oui
    Dim myCalItems As Outlook.items 'oui
    Dim ItemstoCheck As Outlook.items
    Dim ThisAppt As Outlook.AppointmentItem 'oui
    Dim MyItem As Object
    Dim StringToCheck As String
    Dim MyBook As Excel.Workbook
    Dim rngStart As Excel.Range
    Dim i As Long
    Dim NextRow As Long
     
     
     
    If EndDate < StartDate Then
        MsgBox "Those dates seem switched, please check them and try again.", vbInformation
        GoTo ExitProc
    End If
     
    On Error Resume Next
    Set OlApp = GetObject(, "Outlook.Application")
    If Err.Number <> 0 Then
        Set OlApp = CreateObject("Outlook.Application")
    End If
    On Error GoTo 0
    If OlApp Is Nothing Then
        MsgBox "Cannot start Outlook.", vbExclamation
        GoTo ExitProc
    End If
    Set olNS = OlApp.GetNamespace("MAPI")
    Set myCalItems = olNS.GetDefaultFolder(olFolderCalendar).items
     
     
    With myCalItems
        .Sort "[Start]", False
        .IncludeRecurrences = True
    End With
    '
    StringToCheck = "[Start] >= " & Quote(StartDate & " 12:00 AM") & " AND [End] <= " & _
    Quote(EndDate & " 11:59 PM")
    Debug.Print StringToCheck
    '
    Set ItemstoCheck = myCalItems.Restrict(StringToCheck)
    Debug.Print ItemstoCheck.Count
    ' ------------------------------------------------------------------
    If ItemstoCheck.Count > 0 Then
        If ItemstoCheck.Item(1) Is Nothing Then GoTo ExitProc
            Set MyBook = ThisWorkbook
            Set rngStart = ThisWorkbook.Sheets(1).Range("C1")
            With rngStart
                .Offset(0, 0).Value = "Date"
                .Offset(0, 1).Value = "Subject"
                .Offset(0, 2).Value = "Duration"
                .Offset(0, 3).Value = "Location"
                .Offset(0, 4).Value = "Categories"
                .Offset(0, 5).Value = "Organisateur"
                .Offset(0, 6).Value = "Destinataires"
            End With
            For Each MyItem In ItemstoCheck
                If MyItem.Class = OlAppointment Then
                    Set ThisAppt = MyItem
                    NextRow = Range("C" & Rows.Count).End(xlUp).Row
                    With rngStart
                        .Offset(NextRow, 0).Value = ThisAppt.Start
                        .Offset(NextRow, 1).Value = ThisAppt.Subject
                        .Offset(NextRow, 2).Value = ThisAppt.Duration & " Min"
                        .Offset(NextRow, 3).Value = ThisAppt.Location
                        .Offset(NextRow, 4).Value = ThisAppt.Categories
                        .Offset(NextRow, 5).Value = ThisAppt.Organizer
                        .Offset(NextRow, 6).Value = ThisAppt.RequiredAttendees
     
                    End With
                End If
            Next MyItem
            Call Cool_Colors(rngStart)
        Else
            MsgBox "There are no appointments or meetings during" & _
            "the time you specified. Exiting now.", vbCritical
        End If
    ExitProc:
    Set myCalItems = Nothing
    Set ItemstoCheck = Nothing
    Set olNS = Nothing
    Set OlApp = Nothing
    Set rngStart = Nothing
    Set ThisAppt = Nothing
    End Sub
     
    Private Function Quote(MyText)
    Quote = Chr(34) & MyText & Chr(34)
    End Function
     
    Private Sub Cool_Colors(rng As Excel.Range)
    With Range("C1:I1")
        .Font.ColorIndex = 2
        .Font.Bold = True
        With .Interior
            .ColorIndex = 23
            .Pattern = xlSolid
        End With
    End With
    End Sub

    cordialement

  7. #7
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour,

    je me suis emballé lorsque j'ai vu apparaitre le calendrier en faisant ma recherche avec l'adresse "planning technique -paul.trucmuch@usine.info"
    en fait il m'affiche mon planning personnel (je pense qu'il ne prend en compte que l'adresse mail)

    pour la ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Set CalendarFolder = _
            myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
    il affecte la valeur "paul.trucmuch" à "myRecipient"
    et il affecte "9" à "olFolderCalendar"


    lorsque je prend uniquement l'adresse "planning technique" j'ai un message d'erreur "l'adresse ne correspond pas à un utilisateur"


    j'ai demandé à mon collegue ou se trouve ce palnning et il est à cette adresse: "planningtechnique@usinecloud.onmicrosoft.com"


    lorsque le prend cette adresse j'ai un message d'erreur,"l'adresse ne correspond pas à un utilisateur de courrier" je pense que la methode de recherche du fichier est erroné,


    si quelqu'un pouvait m'aider ce serait sympa,

    merci d'avance

  8. #8
    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
    Si le calendrier est visible dans tes calendriers tu peux faire 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
     
    Sub TrouveCalendrierPartagé()
    '---------------------------------------------------------------------------------------
    ' Procedure : ListeCalendrierPartagé
    ' Author    : Oliv-
    ' Date      : 19/02/2014
    ' Purpose   : Liste les des "calendrier partagé" et le Dossier correpondant
    '---------------------------------------------------------------------------------------
    '
        Dim objNS As Outlook.NameSpace
        Dim objExpCal As Outlook.Explorer
        Dim objNavMod As Outlook.CalendarModule
        Dim objNavCalPart As Outlook.NavigationFolders
        Dim i, objitem
     
        Nom = "LE NOM"
     
        Set objNS = Application.Session
        Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
        Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
     
     
        Set objNavCalPart = objNavMod.NavigationGroups.Item("tous les calendriers de groupe").NavigationFolders
        For i = 1 To objNavCalPart.count
            If objNavCalPart(i).displayName = Nom Then
                Set objitem = objNavCalPart(i)
                On Error Resume Next
     
                FoldName = objitem.Folder.Name & "-" & objitem.Folder.FullFolderPath
                If Err Then FoldName = "Pas accessible"
                Debug.Print objitem & "-->" & FoldName
     
                strDate = VBA.Format(Date - 2, "Short Date")
     
                strRestriction = "(([Start] >= '" & strDate & " 12:00 am' )"    'AND [Start] <= '" & strDate & " 11:59 pm')"
                strRestriction = strRestriction & ")"
                On Error GoTo 0
                Set Rdv = objitem.Folder.Items.Restrict(strRestriction)
                For j = 1 To Rdv.count
     
                    If Rdv(j).Start >= strDate Then
                        MsgBox "stop"
                        Stop
                    End If
                    'Debug.Print rdv(j).subject
                Next j
                'Exit For
            End If
        Next i
     
     
     
    End Sub

  9. #9
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour,

    merci pour la reponse,

    j'ai une erreur 438 sur la ligne
    propriété ou méthode non gérée par cet objet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Set objNS = Application.Session
    cordialement

  10. #10
    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
    mon exemple était pour OUTLOOK
    modifier ligne 18

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     Dim myOlApp As Outlook.Application
     
        Set myOlApp = CreateObject("Outlook.Application")
    Set objNS = myOlApp.Session

  11. #11
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour,

    j'ai corrigé mais j'ai une autre erreur sur la ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Set objNavCalPart = objNavMod.NavigationGroups.Item("tous les calendriers de groupe").NavigationFolders
    variable ou objet bloc wiht non definie
    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
    Sub TrouveCalendrierPartagé()
    '---------------------------------------------------------------------------------------
    ' Procedure : ListeCalendrierPartagé
    ' Author    : Oliv-
    ' Date      : 19/02/2014
    ' Purpose   : Liste les des "calendrier partagé" et le Dossier correpondant
    '---------------------------------------------------------------------------------------
    '
        Dim objNS As Outlook.Namespace
        Dim objExpCal As Outlook.Explorer
        Dim objNavMod As Outlook.CalendarModule
        Dim objNavCalPart As Outlook.NavigationFolders
        Dim i, objitem
        Dim myOlApp As Outlook.Application
     
        Nom = "planningtechnique"
        Set myOlApp = CreateObject("Outlook.Application")
        Set objNS = myOlApp.Session
     
        Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
        Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
     
     
        Set objNavCalPart = objNavMod.NavigationGroups.Item("tous les calendriers de groupe").NavigationFolders
        For i = 1 To objNavCalPart.Count
            If objNavCalPart(i).DisplayName = Nom Then
                Set objitem = objNavCalPart(i)
                On Error Resume Next
     
                FoldName = objitem.Folder.Name & "-" & objitem.Folder.FullFolderPath
                If Err Then FoldName = "Pas accessible"
                Debug.Print objitem & "-->" & FoldName
     
                strDate = VBA.Format(Date - 2, "Short Date")
     
                strRestriction = "(([Start] >= '" & strDate & " 12:00 am' )"    'AND [Start] <= '" & strDate & " 11:59 pm')"
                strRestriction = strRestriction & ")"
                On Error GoTo 0
                Set Rdv = objitem.Folder.items.Restrict(strRestriction)
                For j = 1 To Rdv.Count
     
                    If Rdv(j).Start >= strDate Then
                        MsgBox "stop"
                        Stop
                    End If
                    'Debug.Print rdv(j).subject
                Next j
                'Exit For
            End If
        Next i
     End Sub

    cordialement

  12. #12
    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
    Ok j'ai vu le problème, les noms sont sensibles à la casse.

    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
    Sub TrouveCalendrierPartagé()
    '---------------------------------------------------------------------------------------
    ' Procedure : ListeCalendrierPartagé
    ' Author    : Oliv-
    ' Date      : 19/02/2014
    ' Purpose   : Liste les des "calendrier partagé" et le Dossier correpondant
    '---------------------------------------------------------------------------------------
    '
        Dim objNS As Outlook.Namespace
        Dim objExpCal As Outlook.Explorer
        Dim objNavMod As Outlook.CalendarModule
        Dim objNavCalPart As Outlook.NavigationFolders
        Dim i, objitem
     
        Nom = "AMBASSADEURS"
     
        Set ol = CreateObject("outlook.application")
        Set objNS = ol.Session
        Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
        Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
     
        Set objcalgr = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe")
        Set objNavCalPart = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe").NavigationFolders
        For i = 1 To objNavCalPart.Count
    debug.print objNavCalPart(i).DisplayName 
            If objNavCalPart(i).DisplayName = Nom Then
                Set objitem = objNavCalPart(i)
                On Error Resume Next
     
                FoldName = objitem.Folder.Name & "-" & objitem.Folder.FullFolderPath
                If Err Then FoldName = "Pas accessible"
                Debug.Print objitem & "-->" & FoldName
     
                'strDate = VBA.Format(Date - 2, "Short Date")
     
                'strRestriction = "(([Start] >= '" & strDate & " 12:00 am' )"    'AND [Start] <= '" & strDate & " 11:59 pm')"
                'strRestriction = strRestriction & ")"
                On Error GoTo 0
                Set rdv = objitem.Folder.Items    '.Restrict(strRestriction)
                For j = 1 To rdv.Count
     
                    Debug.Print rdv(j).Subject
                Next j
                'Exit For
            End If
        Next i
     
     
     
    End Sub

  13. #13
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour,

    c'est super, j'avance,
    j'ai remplacé "AMBASSADEURS" par "Planning Technique" et tous les 5 calendriers sont bien passé en revu,
    en mode pas à pas je il fait bien la boucle j pour le "Planning Technique" mais pas d'affichage sur ma feuille excel,

    une question bête, par quoi je remplace "Tous les calendriers de groupe" ? lorsque je met le nom d'un calendrier ca ne fonctionne plus,


    comment faire pour remplir la feuille excel avec la date, le sujet etc....?

    j'ai ajouté la ligne 43 mais rien sur la feuille Excel

    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
    Sub TrouveCalendrierPartagé()
    '---------------------------------------------------------------------------------------
    ' Procedure : ListeCalendrierPartagé
    ' Author    : Oliv-
    ' Date      : 19/02/2014
    ' Purpose   : Liste les des "calendrier partagé" et le Dossier correpondant
    '---------------------------------------------------------------------------------------
    '
        Dim objNS As Outlook.Namespace
        Dim objExpCal As Outlook.Explorer
        Dim objNavMod As Outlook.CalendarModule
        Dim objNavCalPart As Outlook.NavigationFolders
        Dim i, objitem
     
        Nom = "Planning Technique"
     
        Set OL = CreateObject("outlook.application")
        Set objNS = OL.Session
        Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
        Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
     
        Set objcalgr = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe")
        Set objNavCalPart = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe").NavigationFolders
        For i = 1 To objNavCalPart.Count
    Debug.Print objNavCalPart(i).DisplayName
            If objNavCalPart(i).DisplayName = Nom Then
                Set objitem = objNavCalPart(i)
                On Error Resume Next
     
                FoldName = objitem.Folder.Name & "-" & objitem.Folder.FullFolderPath
                If Err Then FoldName = "Pas accessible"
                Debug.Print objitem & "-->" & FoldName
     
                strdate = VBA.Format(Date - 2, "Short Date")
     
                strRestriction = "(([Start] >= '" & strdate & " 12:00 am' )"    'AND [Start] <= '" & strDate & " 11:59 pm')"
                strRestriction = strRestriction & ")"
                On Error GoTo 0
                Set rdv = objitem.Folder.items    '.Restrict(strRestriction)
                For j = 1 To rdv.Count
     
                    'Debug.Print rdv(j).Subject
                    Cells(j, 2).Value = Subject
                Next j
                'Exit For
            End If
        Next i
     
     
     
    End Sub

    cordialement

  14. #14
    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
    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
    Sub TrouveCalendrierPartagé()
    '---------------------------------------------------------------------------------------
    ' Procedure : ListeCalendrierPartagé
    ' Author    : Oliv-
    ' Date      : 19/02/2014
    ' Purpose   : Liste les des "calendrier partagé" et le Dossier correpondant
    '---------------------------------------------------------------------------------------
    '
        Dim objNS As Outlook.Namespace
        Dim objExpCal As Outlook.Explorer
        Dim objNavMod As Outlook.CalendarModule
        Dim objNavCalPart As Outlook.NavigationFolders
        Dim i, objitem
     
        Nom = "planning technique"
     
        Set ol = CreateObject("outlook.application")
        Set objNS = ol.Session
        Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
        Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
     
        Set objcalgr = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe")
        Set objNavCalPart = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe").NavigationFolders
        For i = 1 To objNavCalPart.Count
    debug.print objNavCalPart(i).DisplayName 
            If instr(1,objNavCalPart(i).DisplayName,Nom,vbtextcompare) >0 Then
                Set objitem = objNavCalPart(i)
                On Error Resume Next
     
                FoldName = objitem.Folder.Name & "-" & objitem.Folder.FullFolderPath
                If Err Then FoldName = "Pas accessible"
                Debug.Print objitem & "-->" & FoldName
     
                'strDate = VBA.Format(Date - 2, "Short Date")
     
                'strRestriction = "(([Start] >= '" & strDate & " 12:00 am' )"    'AND [Start] <= '" & strDate & " 11:59 pm')"
                'strRestriction = strRestriction & ")"
                On Error GoTo 0
                Set rdv = objitem.Folder.Items    '.Restrict(strRestriction)
                For j = 1 To rdv.Count
     
                    Debug.Print rdv(j).Subject
                Next j
                'Exit For
            End If
        Next i
     
     
     
    End Sub

  15. #15
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour,

    merci pour votre patience,
    malheureusement je n'ai toujours rien sur ma feuille excel, la feuille reste vide,

    j'ai copier coller le programmme, je l'ai lancé, il ne se passe rien sur la feuille excel, la boucle J fait bien les 448 passages sur "Debug.Print rdv(j).Subject"
    mais rien ne s'affiche sur la feuille excel


    les valeur que j'arrive à voir en pointant sur la ligne:
    objNS = "MAPI"
    objExpCal = ???
    objNavMod = "Calendrier"
    objNavCalPart = ???
    objitem = "Planning Technique"
    Nom ="Planning Technique"
    OL = "Outlock
    objcalgr = "Tous les calendriers de groupe"
    objNavCalPart.Count = 5
    DiplayName = ???
    FoldName = "Planning Technique-\\paul.trucmuch@usine.info\calendars\Planning Technique"
    vbTextCompare = 1
    objNavCalPart(i) = "planning Technique" et ensuite les autres nom de calendrier
    rdv = ???
    Subject = ???



    cordialement

  16. #16
    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
    as tu mixé mon code avec le tien qui fait la copie vers excel ?

    parce que le mien ne comporte rien à ce sujet

  17. #17
    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
    essaye avec ce code
    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
    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
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    Sub TrouveCalendrierPartagé()
    '---------------------------------------------------------------------------------------
    ' Procedure : ListeCalendrierPartagé
    ' Author    : Oliv-
    ' Date      : 19/02/2014
    ' Purpose   : Liste les des "calendrier partagé" et le Dossier correpondant
    '---------------------------------------------------------------------------------------
    '
    Dim objNS As Outlook.Namespace
    Dim objExpCal As Outlook.Explorer
    Dim objNavMod As Outlook.CalendarModule
    Dim objNavCalPart As Outlook.NavigationFolders
    Dim i, objitem As Object
     
    Nom = "planning technique"
     
    Set OL = CreateObject("outlook.application")
    Set objNS = OL.Session
    Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
    Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
     
    Set objcalgr = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe")
    Set objNavCalPart = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe").NavigationFolders
    For i = 1 To objNavCalPart.Count
        Debug.Print objNavCalPart(i).DisplayName
        If InStr(1, objNavCalPart(i).DisplayName, Nom, vbTextCompare) > 0 Then
            Set objitem = objNavCalPart(i)
            On Error Resume Next
     
            FoldName = objitem.Folder.Name & "-" & objitem.Folder.FullFolderPath
            If Err Then FoldName = "Pas accessible"
            Debug.Print objitem & "-->" & FoldName
            Call ExportFolderAppointmentsToExcel(objitem.Folder)
     
            Exit For
        End If
    Next i
     
     
     
    End Sub
     
     
     
     
     
    Sub ExportFolderAppointmentsToExcel(oFolder As Object)
    '---------------------------------------------------------------------------------------
    ' Procedure : ExportFolderAppointmentsToExcel
    ' Author    : OCTU
    ' Date      : 10/09/2020
    ' Purpose   :
    '---------------------------------------------------------------------------------------
    '
        Dim criteria
        Dim oTable As Object
        Dim i, oRow, R, arr
     
        Const olFolderInbox = 6
        Const olUserItems = 0
     
     
     
     
        'Pour ne prendre que les EMAILS
        'criteria = "[MessageClass]='IPM.Note' or [MessageClass]='IPM.Post'"
     
        'Pour tous les éléments
        criteria = "[MessageClass]<>'zzz'"
     
     
        Set oTable = oFolder.GetTable(criteria, olUserItems)
        MsgBox oTable.GetRowCount
        On Error Resume Next
        '    With oTable.Columns
        '        .RemoveAll
        '        .Add ("Subject")
        '        .Add ("CreationTime")
        '        .Add ("LastModificationTime")
        '        .Add ("MessageClass")
        '        .Add ("ReceivedTime")
        '        .Add ("Senton")
        '        .Add ("Size")
        '        .Add ("To")
        '        .Add ("Cc")
        '        .Add ("Bcc")
        '        .Add ("Categories")
        '        .Add ("ConversationTopic")
        '        .Add ("ReceivedByName")
        '        .Add ("SenderName")
        '        .Add ("SenderEmailAddress")
        '        .Add ("Unread")
        '        .Add ("http://schemas.microsoft.com/mapi/proptag/0x0E1B000B")    'PR_HASATTACH
        '        .Add ("ConversationIndex")
        '        .Add ("http://schemas.microsoft.com/mapi/proptag/0x66700102")
        '        .Add ("http://schemas.microsoft.com/mapi/proptag/0x1000001F")    '="Body"
        '        ''.Add ("Sent") 'KO
        '        ''.Add ("Duration") 'KO
        '        ''.Add ("Type") 'KO
        '
        '    End With
        'MsgBox oTable.GetRowCount
     
        Dim AppExcel As Object
        Dim Wk As Object, Ws As Object
        If InStr(1, Application, "Excel", vbTextCompare) > 0 Then
            Set AppExcel = Application
        Else
            Set AppExcel = CreateObject("Excel.application")
            AppExcel.Visible = True
        End If
        Set Wk = AppExcel.Workbooks.Add
        Set Ws = Wk.ActiveSheet
     
        R = 2
        'Enumerate the table using test for EndOfTable
        For i = 1 To oTable.Columns.Count
            Ws.Cells(1, i).Value = oTable.Columns.Item(i).Name
            If Ws.Cells(1, i).Value = "http://schemas.microsoft.com/mapi/proptag/0x0E1B000B" Then Ws.Cells(1, i).Value = "PR_HASATTACH"
            If Ws.Cells(1, i).Value = "http://schemas.microsoft.com/mapi/proptag/0x66700102" Then Ws.Cells(1, i).Value = "EntryIdLong"
            If Ws.Cells(1, i).Value = "http://schemas.microsoft.com/mapi/proptag/0x1000001F" Then Ws.Cells(1, i).Value = "Body"
        Next i
        Ws.Cells.NumberFormat = "@"
        Ws.Range("C:H").NumberFormat = "General"
     
        'GoTo parcourir
        '     one row spanning several columns
        oTable.Sort "LastModificationTime", True
        arr = oTable.GetArray(oTable.GetRowCount)
     
        Dim Destination As Range
        Set Destination = Ws.Range("a2")
        Set Destination = Destination.Resize(UBound(arr, 1) + 1 - LBound(arr, 1), UBound(arr, 2) + 1 - LBound(arr, 2))
     
        On Error Resume Next
        Destination.Value = arr
     
        If Err = 1004 Then GoTo parcourir
        'quand cela ne marche pas cela vient du format de la colonne destination
        On Error GoTo 0
        GoTo mef
     
        'AUTRE METHODE on ecrit en parcourant les enregistrement et les colonnes
    parcourir:
        'pour parcourir la table champs par champs
        oTable.MoveToStart
        Do Until (oTable.EndOfTable)
            On Error Resume Next
            Set oRow = oTable.GetNextRow()
            For i = 1 To oTable.Columns.Count
                Debug.Print oRow("Body")
                AppExcel.Cells(R, i).Value = oRow(oTable.Columns(i).Name)
            Next i
     
            R = R + 1
        Loop
     
        GoTo mef
     
    mef:
     
        'mise en forme
        With Ws.Cells
            .AutoFilter
            .EntireColumn.AutoFit
        End With
     
        With Ws.Rows("1:1").Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
            .PatternTintAndShade = 0
            .Parent.Font.Bold = True
        End With
        Ws.Cells.WrapText = True
        Ws.Cells.WrapText = False
        Exit Sub
     
    End Sub

  18. #18
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    Bonjour,

    un grand merci ca marche super bien et en plus à une vitesse phenomenale,


    j'ai réussi à rester sur ma feuille en supprimant la création d'un nouveau classeur,
    mainteant j'aimerais savoir comment je fait pour selectionner les champs que je souhaite afficher,
    par exemple je voudrais supprimer le champs "EntryID" et ajouter les destinataires
    je voudrais egalement changer l'ordre d'affichage des champs,


    voici ou jen suis actuelement:

    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
    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
    Sub TrouveCalendrierPartagé()
    '---------------------------------------------------------------------------------------
    ' Procedure : ListeCalendrierPartagé
    ' Author    : Oliv-
    ' Date      : 19/02/2014
    ' Purpose   : Liste les des "calendrier partagé" et le Dossier correpondant
    '---------------------------------------------------------------------------------------
    Dim objNS As Outlook.Namespace
    Dim objExpCal As Outlook.Explorer
    Dim objNavMod As Outlook.CalendarModule
    Dim objNavCalPart As Outlook.NavigationFolders
    Dim i, objitem As Object
     
    Sheets("Feuil1").Select
        Range("A1").Select
    Range("C2:I1000").Select
    Selection.ClearContents
     
     
    Nom = "planning technique"
    Set OL = CreateObject("outlook.application")
    Set objNS = OL.Session
    Set objExpCal = objNS.GetDefaultFolder(olFolderCalendar).GetExplorer
    Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(olModuleCalendar)
    Set objcalgr = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe")
    Set objNavCalPart = objNavMod.NavigationGroups.Item("Tous les calendriers de groupe").NavigationFolders
    For i = 1 To objNavCalPart.Count
        Debug.Print objNavCalPart(i).DisplayName
        If InStr(1, objNavCalPart(i).DisplayName, Nom, vbTextCompare) > 0 Then
            Set objitem = objNavCalPart(i)
            On Error Resume Next
            FoldName = objitem.Folder.Name & "-" & objitem.Folder.FullFolderPath
            If Err Then FoldName = "Pas accessible"
            Debug.Print objitem & "-->" & FoldName
            Call ExportFolderAppointmentsToExcel(objitem.Folder)
            Exit For
        End If
    Next i
    Sheets("Feuil3").Select
        Range("A1").Select
    End Sub
    Sub ExportFolderAppointmentsToExcel(oFolder As Object)
    '---------------------------------------------------------------------------------------
    ' Procedure : ExportFolderAppointmentsToExcel
    ' Author    : OCTU
    ' Date      : 10/09/2020
    ' Purpose   :
    '---------------------------------------------------------------------------------------
        Dim criteria
        Dim oTable As Object
        Dim i, oRow, R, arr
        Const olFolderInbox = 6
        Const olUserItems = 0
        'Pour tous les éléments
        criteria = "[MessageClass]<>'zzz'"
        Set oTable = oFolder.GetTable(criteria, olUserItems)
        'MsgBox oTable.GetRowCount
        On Error Resume Next
        R = 2
        'Enumerate the table using test for EndOfTable
        For i = 1 To oTable.Columns.Count
            Cells(1, i + 2).Value = oTable.Columns.Item(i).Name
            If Cells(1, i + 2).Value = "http://schemas.microsoft.com/mapi/proptag/0x0E1B000B" Then Ws.Cells(1, i + 2).Value = "PR_HASATTACH"
            If Cells(1, i + 2).Value = "http://schemas.microsoft.com/mapi/proptag/0x66700102" Then Ws.Cells(1, i + 2).Value = "EntryIdLong"
            If Cells(1, i + 2).Value = "http://schemas.microsoft.com/mapi/proptag/0x1000001F" Then Ws.Cells(1, i + 2).Value = "Body"
        Next i
        Cells.NumberFormat = "@"
        Range("C:I").NumberFormat = "General"
        oTable.Sort "LastModificationTime", True
        arr = oTable.GetArray(oTable.GetRowCount)
     
        Dim Destination As Range
        Set Destination = Range("C2")
        Set Destination = Destination.Resize(UBound(arr, 1) + 1 - LBound(arr, 1), UBound(arr, 2) + 1 - LBound(arr, 2))
     
        On Error Resume Next
        Destination.Value = arr
     
        If Err = 1004 Then GoTo parcourir
        'quand cela ne marche pas cela vient du format de la colonne destination
        On Error GoTo 0
        GoTo mef
     
        'AUTRE METHODE on ecrit en parcourant les enregistrement et les colonnes
    parcourir:
        'pour parcourir la table champs par champs
        oTable.MoveToStart
        Do Until (oTable.EndOfTable)
            On Error Resume Next
            Set oRow = oTable.GetNextRow()
            For i = 1 To oTable.Columns.Count
                Debug.Print oRow("Body")
                AppExcel.Cells(R, i).Value = oRow(oTable.Columns(i).Name)
            Next i
     
            R = R + 1
        Loop
     
        GoTo mef
     
    mef:
     
        'mise en forme
        With Cells
            .AutoFilter
            .EntireColumn.AutoFit
        End With
     
        With Rows("1:1").Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
            .PatternTintAndShade = 0
            .Parent.Font.Bold = True
        End With
        Cells.WrapText = True
        Cells.WrapText = False
        Exit Sub
     
    End Sub

    cordialement

  19. #19
    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
    c'est assez évident non ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Set Wk = AppExcel.ActiveWorkbook

  20. #20
    Membre du Club
    Homme Profil pro
    Getion appro planning
    Inscrit en
    Août 2020
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Getion appro planning
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2020
    Messages : 39
    Points : 40
    Points
    40
    Par défaut
    oui j'ai réussi en supprimant tout ce qui etait en rapport avec Ws et Wk

    maintenant pour faire vraiment dans la finition j'aimerai pouvoir choisir les champs et l'ordre de d'affichage des champs

    et inclure une restriction de date du style" date -8 et date +60"

    cordialement

Discussions similaires

  1. Export Calendrier Outlook
    Par KIXE80 dans le forum VBA Outlook
    Réponses: 16
    Dernier message: 04/07/2020, 20h54
  2. [XL-2010] Exporter Calendrier Outlook
    Par omarter dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 16/01/2015, 17h34
  3. Réponses: 0
    Dernier message: 14/04/2013, 21h16
  4. Afficher le calendrier outlook depuis une applications windows form
    Par vb_programmeur dans le forum Windows Forms
    Réponses: 1
    Dernier message: 08/12/2010, 13h16
  5. [MySQL] Exporter des données vers Excel depuis php
    Par berti dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 05/03/2008, 14h26

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