Bonjour à tous,

Je developpe sur Xp Sp2 / Access2007

J'importe et j'exporte des contacts de Outlook 2007 grace aux contributions de ce forum et surtout de Heureux-oli
Je n'ai, bien sûr pas pu m'empêcher de mettre à ma sauce.
En particulier en filtrant les contacts à importer (Otl>Acc) par Categorie.
Ca marche bien:
Remplissage d'une combo avec les Catégories
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
Private Sub cmdImportOutlook_Click()
 
    Me.cmbCategorie.Visible = True
    subListerCategories 'Rempli la liste des catégories
    Me.cmbCategorie.Value = "Sélectionnez une catégorie"
End Sub
Listing des catégories pour remplir la combo
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
Private Sub subListerCategories()
    Dim objNameSpace As NameSpace
    Dim objCategory As Category
    Dim olApp As Outlook.Application
    ' Obtain a NameSpace object reference.
    Set olApp = Outlook.Application
    Set objNameSpace = olApp.GetNamespace("MAPI")
 
    ' Check if the Categories collection for the Namespace
    ' contains one or more Category objects.
    If objNameSpace.Categories.Count > 0 Then
        ' Enumerate the Categories collection.
        For Each objCategory In objNameSpace.Categories
            Me.cmbCategorie.AddItem (objCategory.Name)
        Next
    End If
    Me.cmbCategorie.AddItem ("Toutes....................")
    Set objCategory = Nothing
    Set objNameSpace = Nothing
 
End Sub
Parcours des contacts correspondants après choix dans la combo
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
Private Sub cmbCategorie_AfterUpdate()
    Dim oCont As ContactItem
    Dim oFold As MAPIFolder
    Dim nM As NameSpace
    Dim olApp As Outlook.Application
    retourAccesADB = True
 
    Dim strLastName As String, strFirstName As String, strCompanyName As String, strJobTitle As String
    Dim strBusinessTelephoneNumber As String, strMobileTelephoneNumber As String
    Dim strBusinessFaxNumber As String, strEmail1Address As String
    ' Affectation des objets
    Set olApp = Outlook.Application
    Set nM = olApp.GetNamespace("MAPI")
    Set oFold = nM.GetDefaultFolder(olFolderContacts)
 
    For Each oCont In oFold.Items
        If InStr(1, oCont.Categories, Me.cmbCategorie.Value) Or Me.cmbCategorie.Value = "Toutes...................." Then
                    If retourAccesADB = True Then
                strLastName = Nz(CStr(oCont.LastName), " ")
                strFirstName = Nz(CStr(oCont.FirstName), " ")
                strCompanyName = Nz(oCont.CompanyName, "")
                strJobTitle = Nz(CStr(oCont.JobTitle), "")
                strBusinessTelephoneNumber = Nz(CStr(oCont.BusinessTelephoneNumber), " ")
                strMobileTelephoneNumber = Nz(CStr(oCont.MobileTelephoneNumber), " ")
                strBusinessFaxNumber = Nz(CStr(oCont.BusinessFaxNumber), " ")
                strEmail1Address = Nz(CStr(oCont.Email1Address), " ")
 
                AccesADB strLastName, strFirstName, strCompanyName, strJobTitle, strBusinessTelephoneNumber, strMobileTelephoneNumber, strBusinessFaxNumber, strEmail1Address
 
            Else
                Exit For
            End If
 
        End If
 
    Next oCont
    MsgBox "Plus de Contacts dans cette catégorie.", vbInformation, "xxx"
 
End Sub
Arrivé sur un poste Vista/Runtime 2007/Office 2003: ça ne va plus.
La commande
cmdImportOutlook_Click
plante l'application (malgré une gestion d'erreur).
Si je bypasse le remplissage de liste et je fournis le contenu d'une textbox saisie à la main à
cmbCategorie_AfterUpdate
ça fonctionne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
        'If InStr(1, oCont.Categories, Me.cmbCategorie.Value) Or Me.cmbCategorie.Value = "Toutes...................." Then
        If InStr(1, oCont.Categories, Me.txtCategorie.Value) Then
Enfin, dans ce cas j'ai un message
Ms Off Outlook ne peut pas executer les complements.
Ce composant n'est pas installé.
Souhaitez vous l'installer maintenant?
Et l'installation se fait sans problème.
De quel composant s'agit-il?
Dernière précision (et là, je ne sais pas si ma façon de faire est correcte).
L'appli fait référence au msoutl.olb qui se trouve dans \Office12\, j'y ai donc posé ce fichier. (je rappelle que c'est office 2003 qui est installé sur ce poste).
Merci de votre attention.