Bonjour,

J'utilise Office 2003 SP3.
A partir d'une base Access, je souhaite copier une feuille excel vers un autre fichier excel.

Voici 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
Private Sub cmdxls_Click()
On Error GoTo Err_cmdxls_Click
Dim xlApp1 As Excel.Application
Dim xlsheet1 As Excel.Worksheet
Dim xlBook1 As Excel.Workbook
Dim xlApp2 As Excel.Application
Dim xlsheet2 As Excel.Worksheet
Dim xlBook2 As Excel.Workbook
 
Set xlApp1 = CreateObject("Excel.Application")
Set xlBook1 = xlApp1.Workbooks.Open("C:\Mes documents\donneesdepart.xls")
Set xlsheet1 = xlBook1.Worksheets("Input")
Set xlApp2 = CreateObject("Excel.Application")
Set xlBook2 = xlApp2.Workbooks.Open("C:\Mes documents\resultat.xls")
 
xlsheet1.Copy after:=xlBook2.Worksheets(xlBook2.Worksheets.Count)
 
xlApp1.Quit
xlApp2.Quit
Set xlBook1 = Nothing
Set xlApp1 = Nothing
Set xlsheet1 = Nothing
Set xlBook2 = Nothing
Set xlApp2 = Nothing
 
 
Exit_cmdxls_Click:
    Exit Sub
 
Err_cmdxls_Click:
    MsgBox Err.Description
    Resume Exit_cmdxls_Click
 
End Sub
Lorsque j'exécute mon code, il m'affiche :
La méthode 'Copy' de la classe '_worksheet' a échoué.

Cela fait 2 heures que je recherche une solution sur ce site, sans résultat...
Quelqu'un(e) peut m'aider, SVP merci ?

Anne