Bonjour,

Dans un de mes programmes excel, je dois prendre des informations sélectionnées dans un ficher excel 1 : "DQ 8510 002 Plan d'action 1" pour le mettre dans un fichier excel 2 : "DQ 8510 002 Plan d'action 1" (c'est sur le fichier 2 que j'ai ma macro"

Pour ce faire je dois passer d'un fichier à l'autre et c'est là que j'ai pas mal de difficulté

voila le début de mon 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
Private Sub CommandButton1_Click()
 
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
Dim i As Integer
Dim j As Integer
Dim A As Integer
Dim b As Integer
 
 
' nom utilisateur
Name = "XXXX"
 
 
'destruction du plan d'action actuel
 
i = 6
 
While Cells(i, 1) <> ""
    Rows("i:i").Select
    Selection.Delete
    i = i + 1
Wend
 
 
 
'vérification de l'existance du plan d'action 2
 
If FichierExiste("M:\QSE\qualite\Processus amélioration\Plan d'action et fiche projet\DQ 8510 002 Plan d'action 1.xls") = True Then
 
    'Ouverture de l'application
    Set appExcel = CreateObject("Excel.Application")
    'Ouverture d'un fichier Excel
    appExcel.Visible = True
    Set wbExcel = appExcel.Workbooks.Open("M:\QSE\qualite\Processus amélioration\Plan d'action et fiche projet\DQ 8510 002 Plan d'action 1.xls")
    'wsExcel correspond à la première feuille du fichier
    Set wsExcel = wbExcel.Worksheets(1)
 
    i = 6
    j = 6
    A = 6
    b = 1
 
 
    Windows("DQ 8510 002 Plan d'action 1.xls").activate' C'est à ce moment là que VBA bug et qu'il me met "erreur 9 , l'indice n'appartient pas à la sélection)
    Worksheets(1).Select
 
 
 
End If
 
End Sub

J'ai essayé le nom avec : "Microsoft Excel - DQ 8510 002 Plan d'action 1.xls", "DQ 8510 002 Plan d'action 1" et "Microsoft Excel - DQ 8510 002 Plan d'action 1" et rien ne marche, il fait toujours la même erreur


Merci d'avance