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
| Dim rs As Recordset
Dim ReqSQL As String
Dim fichier_doc As String
Dim xlApp As Excel.application
Dim xlSheet As Excel.Worksheet
Dim xlBook As Excel.Workbook
Dim t0 As Long, t1 As Long
On Error GoTo errGeneration_Doc
ReqSQL = "select * from version"
Set rs = CurrentDb.OpenRecordset(ReqSQL, dbOpenDynaset)
'Selectionne la derniere version
If rs.RecordCount >= 1 Then
rs.MoveLast
End If
fichier_doc = rs.Fields("fichier_doc").Value
fichier_doc = Left(fichier_doc, Len(fichier_doc) - 4) & "_" & langueDoc & Right(fichier_doc, 4)
rs.Close
Set rs = Nothing
'Initialisations
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
If Right(CurDir(), 1) <> "\" Then
fichier_doc = CurDir() + "\" + fichier_doc
Else
fichier_doc = CurDir() + fichier_doc
End If
'Ajouter une feuille de calcul
Set xlSheet = xlBook.Worksheets.Add
'xlSheet.Name = "Modification"
xlBook.SaveAs fichier_doc
xlBook.Saved = True
xlBook.Close
xlApp.Workbooks.Open (fichier_doc)
'Permet de creer un fichier excel à partir d'une requete ou d'une table access
ReqSQL = "historique_" & langueDoc
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, _
ReqSQL, _
fichier_doc, _
True, "Modification"
errGeneration_Doc:
MsgBox "Erreur N° " & err.Number & vbLf & err.Description, , err.Source
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing |
Partager