Bonjour a tous,

Bon l'explication va un peu être longue mais c'est pour bien exposé mon petit souci.

Dans le cadre du boulot, j'ai 2 fichiers Excel
Chaque modification dans une cellule met a jour un fichier Ini qui lui est associé.
Jusque la ça marche impeccable.
Je peux créer dans chaque fichier ini respectif une nouvelle entrée, la modifier ou la supprimer en fonction de ce qui est renseigner par les Users.

Ensuite j'ai voulu monitorer l'activités de mes gars. Pour pouvoir donnes les priorités et automatiser une reporting auprès de la direction.
Du coup 3éme fichier excel qui importe toutes les données des 2 fichiers Ini pour ensuite faire mes tableaux croisé dynamique, graphique, camenbert courbe de charge, etc....
Jusque la ça marche l'importation fonctionne aussi.

Ce que je ne comprend pas par contre c'est que avec l'éditeur VBA, pour tester mes codes, j'y vais en pas a pas (d’abord F8 puis F5 pour l'éxécuter d'un coup.)
Dans ce cas l'importation se fait en 2-3 secondes. ce qui me convient tres bien.

Par contre, je souhaite que cet importation se fasse à l'ouverture du ce fichier. (je sais le faire aussi ça).
Mais ce que je ne comprends pas c'est que l'importation prend 10 bonne minutes.
Qd je vais pose (échap) pour aller dans le débuggeur et que je refais F5, ça repart a toute vitesse.

J'ai l'impression que la lecture d'un fichier Ini n'est rapide que si et seulement si le debuggeur est ouvert.
alors j'ai essayer d'ajouter la commande :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Application.VBE.MainWindow.Visible = True
...
Application.VBE.MainWindow.Visible = False
Mais sans résultat vraiment probent.

Quelqu'un aurais une idée ?

Ci dessous mon code pour importer les données d'un des 2 fichiers Ini.
Le deuxième étant purement identique a l'exception de son nom.

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
 
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
    (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, _
    ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
    (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, _
    ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileSectionNames Lib "kernel32.dll" Alias "GetPrivateProfileSectionNamesA" _
    (ByVal lpszReturnBuffer As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Function EcritDansFichierIni(Section As String, Cle As String, Valeur As String, Fichier As String) As Long
    EcritDansFichierIni = WritePrivateProfileString(Section, Cle, Valeur, Fichier)
End Function
Private Function LitDansFichierIni(Section As String, Cle As String, Fichier As String, _
    Optional ValeurParDefaut As String = "") As String
    Dim strReturn As String
    strReturn = String(255, 0)
    GetPrivateProfileString Section, Cle, ValeurParDefaut, strReturn, Len(strReturn), Fichier
    LitDansFichierIni = Left(strReturn, InStr(strReturn, Chr(0)) - 1)
End Function
Private Function ListeSectionIni(ByVal Path As String, Section() As String)
    Dim strReturn As String
    strReturn = String(8192, 0)
    GetPrivateProfileSectionNames strReturn, Len(strReturn), Path
    Section = Split(Left(strReturn, InStr(1, strReturn, vbNullChar & vbNullChar) - 1), vbNullChar)
End Function
Sub IMPORTATION()
    Dim Section() As String
    i = 5
    CHEMIN_INI = ThisWorkbook.Path
    NAME_INI = CHEMIN_INI & "\ASSIST.ini"
    ListeSectionIni "" & NAME_INI & "", Section '-- Paramètre Section passé ByRef
    For Index = LBound(Section) To UBound(Section)
        If Section(Index) <> "General" Then
            Sheets("PILOTAGE").Cells(i, 2).Value = Section(Index)
            Sheets("PILOTAGE").Cells(i, 1).Value = LitDansFichierIni(Section(Index), "UUID", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 3).Value = LitDansFichierIni(Section(Index), "DESIGNATION", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 4).Value = LitDansFichierIni(Section(Index), "10", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 5).Value = LitDansFichierIni(Section(Index), "20", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 6).Value = LitDansFichierIni(Section(Index), "30", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 7).Value = LitDansFichierIni(Section(Index), "40", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 8).Value = LitDansFichierIni(Section(Index), "50", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 9).Value = LitDansFichierIni(Section(Index), "60", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 10).Value = LitDansFichierIni(Section(Index), "70", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 11).Value = LitDansFichierIni(Section(Index), "80", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 12).Value = LitDansFichierIni(Section(Index), "90", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 13).Value = LitDansFichierIni(Section(Index), "100", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 14).Value = LitDansFichierIni(Section(Index), "110", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 15).Value = LitDansFichierIni(Section(Index), "120", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 16).Value = LitDansFichierIni(Section(Index), "130", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 17).Value = LitDansFichierIni(Section(Index), "140", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 18).Value = LitDansFichierIni(Section(Index), "150", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 19).Value = LitDansFichierIni(Section(Index), "160", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 20).Value = LitDansFichierIni(Section(Index), "?1", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 21).Value = LitDansFichierIni(Section(Index), "?2", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 22).Value = LitDansFichierIni(Section(Index), "?3", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 23).Value = LitDansFichierIni(Section(Index), "?4", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 24).Value = LitDansFichierIni(Section(Index), "?5", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 25).Value = LitDansFichierIni(Section(Index), "?6", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 26).Value = LitDansFichierIni(Section(Index), "ID", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 27).Value = LitDansFichierIni(Section(Index), "Mail", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 28).Value = LitDansFichierIni(Section(Index), "In", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 29).Value = LitDansFichierIni(Section(Index), "Out", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 30).Value = LitDansFichierIni(Section(Index), "Auto-Contrôle", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 31).Value = LitDansFichierIni(Section(Index), "Contrôle", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 32).Value = LitDansFichierIni(Section(Index), "Vérification", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 33).Value = LitDansFichierIni(Section(Index), "Surveillance", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 34).Value = LitDansFichierIni(Section(Index), "Avancement", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 35).Value = LitDansFichierIni(Section(Index), "Statut", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 36).Value = LitDansFichierIni(Section(Index), "?7", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 37).Value = LitDansFichierIni(Section(Index), "?8", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 38).Value = LitDansFichierIni(Section(Index), "?9", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 39).Value = LitDansFichierIni(Section(Index), "Modules communs", "" & NAME_INI & "", 100)
            Sheets("PILOTAGE").Cells(i, 40).Value = LitDansFichierIni(Section(Index), "Stand-by", "" & NAME_INI & "", 100)
            i = i + 1
            Sheets("ACCUEIL").Range("E19").Value = (i - 5) / UBound(Section)
        End If
    Next
End Sub
Merci d'avance pour votre aide, retour, idées, conseils, etc...

Cordialement.