bonjour à toute la communauté,


je fais des macros depuis peu, et je ne comprends pas l'erreur de mon code.

après avoir ouvert un tas de fichiers, je n'arrive pas à activer ces fichiers dans une boucle (car j'aurais beaucoup de manipulations à faire en interaction avec d'autres fichiers)

les fichiers ouverts ont été variablilisés en wb1 wb2 wb3 etc...


mais le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
Windows(wb & i).Activate


me renvoie l'erreur : erreur d'exécution 438, propriété ou méthde non gérée par cet objet



si quelqu'un pouvez m'aider là-dessus, j'en serais ravi

Merci





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
    Dim colFiles As Collection
    Dim wb1, wb2, wb3, wb4, wb5, wb6, wb7, wb8, wb9, wb10, wb11, wb12 As String
 
    Set colFiles = New Collection
    RecursiveFileSearch Ext_EBP, objRegExp, colFiles, objFSO
 
    n = 0       ' nb fichier traité
 
    For Each f In colFiles
        Debug.Print (f)
 
        Select Case f
        Case Ext_EBP & "Factures_Janvier_" & ChoixYear & ".xlsx"
        Set wb1 = Workbooks.Open(f)
        wb1 = ActiveWorkbook.Name
          Case Ext_EBP & "Factures_Février_" & ChoixYear & ".xlsx"
          Set wb = Workbooks.Open(f)
          wb2 = ActiveWorkbook.Name
        Case Ext_EBP & "Factures_Mars_" & ChoixYear & ".xlsx"
        Set wb = Workbooks.Open(f)
        wb3 = ActiveWorkbook.Name
          Case Ext_EBP & "Factures_Avril_" & ChoixYear & ".xlsx"
          Set wb = Workbooks.Open(f)
          wb4 = ActiveWorkbook.Name
        Case Ext_EBP & "Factures_Mai_" & ChoixYear & ".xlsx"
        Set wb = Workbooks.Open(f)
        wb5 = ActiveWorkbook.Name
          Case Ext_EBP & "Factures_Juin_" & ChoixYear & ".xlsx"
          Set wb = Workbooks.Open(f)
          wb6 = ActiveWorkbook.Name
        Case Ext_EBP & "Factures_Juillet_" & ChoixYear & ".xlsx"
        Set wb = Workbooks.Open(f)
        wb7 = ActiveWorkbook.Name
          Case Ext_EBP & "Factures_Août_" & ChoixYear & ".xlsx"
          Set wb = Workbooks.Open(f)
          wb8 = ActiveWorkbook.Name
        Case Ext_EBP & "Factures_Septembre_" & ChoixYear & ".xlsx"
        Set wb = Workbooks.Open(f)
        wb9 = ActiveWorkbook.Name
          Case Ext_EBP & "Factures_Octobre_" & ChoixYear & ".xlsx"
          Set wb = Workbooks.Open(f)
          wb10 = ActiveWorkbook.Name
        Case Ext_EBP & "Factures_Novembre_" & ChoixYear & ".xlsx"
        Set wb = Workbooks.Open(f)
        wb11 = ActiveWorkbook.Name
          Case Ext_EBP & "Factures_Décembre_" & ChoixYear & ".xlsx"
          Set wb = Workbooks.Open(f)
          wb12 = ActiveWorkbook.Name
 
        End Select
        n = n + 1
 
 
    Next
 
    'Garbage Collection
    Set objFSO = Nothing
    Set objRegExp = Nothing
 
 
    ''' Récupération et traitement des données
 
   i = 1
   For i = 1 To n
 
  Windows(wb & i).Activate '................................l'erreur se produit à ce moment
 
 
  '... traiterment sur les fichiers