Bonjour !

Voila j'ai crée une base de donnée access avec gestion de planning et je voudrais faire l'export du planning sous excel.

Tout est fait et marche bien sauf à la création du classeur excel, une fois sur deux (C'est vraiment une fois sur 2 !) jai cette erreur :

"la méthode sheet de l'objet global a échoué"

Voici ou ca plante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
Function makeMonth(currentdate As Date)
    Dim max As Integer
    Dim title As String
        
    title = Format(currentdate, "mmmm")
    Sheets(title).Select
    max = makeHeader(currentdate)
    fullTable currentdate, DateAdd("m", 1, currentdate), max
    fullReunion currentdate, DateAdd("m", 1, currentdate), max
End Function
Voici comment je créer mon fichier excel :

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
Function createFile(ByVal nbMonths As Integer, ByVal Begin As Date, ByVal Ending As Date)
    Dim i As Integer
    Dim title As String
    Dim t1 As String
    Dim t2 As String
 
    i = 1
    Set xlApp = CreateObject("Excel.Application")
    xlApp.SheetsInNewWorkbook = nbMonths
    Set xlBook = xlApp.Workbooks.Add
    xlApp.DisplayAlerts = False
    t1 = Format(Begin, "mmmm yyyy")
    t2 = Format(Ending, "mmmm yyyy")
    If (t1 <> t2) Then
        title = "Planning de Coupure-" & t1 & " à " & t2
    Else
        title = "Planning de Coupure-" & t1
    End If
    xlBook.SaveAs (title & ".xls")
    xlApp.Visible = True
    Do While i <= nbMonths
        Set xlSheet = xlBook.Worksheets(i)
        xlSheet.Name = Format(Begin, "mmmm")
        Set xlSheet = Nothing
        i = i + 1
        Begin = DateAdd("m", 1, Begin)
    Loop
    xlApp.SheetsInNewWorkbook = 3
End Function
et je le ferme comme ca :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
xlBook.save
xlBook.Close 'Fermeture du classeur Excel
xlApp.Quit
'Désallocation mémoire
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Merci d'avance !