A voir également:
- Exportation d'une table Access sous Excel!!!!
- Table ascii - Guide
- Table des matières word - Guide
- Liste déroulante excel - Guide
- Déplacer une colonne excel - Guide
- Word et excel gratuit - Guide
3 réponses
Je n'avais pas pensé o macro! Je ne les utilise jamais!Merci!!!Il me reste tout de même un petit problème : je dois (toujours à partir d'access) insérer une formule de calcul dans excel!!!
Si tu sais comment faire ça m'aiderai beaucoup!!!
Merci encore
calimero
Si tu sais comment faire ça m'aiderai beaucoup!!!
Merci encore
calimero
Salut,
J'utilise un module de class pour les acces a Excel :
Ensuite tu utilises dans un module classique :
Voila si ca peux t'aider...
DaNot
un Libre ouvert à la source...
J'utilise un module de class pour les acces a Excel :
Option Compare Database
Option Explicit
Public gExcelApp As Excel.Application
Public gCurrentWorkbook As Excel.Workbook
Public gCurrentSheet As Excel.Worksheet
Public gCurrentSheetNumber As Integer
Private gExcelAppLaunched As Boolean
Private Sub Class_Initialize()
On Error GoTo NoExcelLaunched
gExcelAppLaunched = False
'Try to get Excel application (if running)
Set gExcelApp = GetObject(, "Excel.Application")
gExcelAppLaunched = True
GoTo CommonEnd
NoExcelLaunched:
On Error GoTo EndOfSub
'No Excel running => Creation
Set gExcelApp = CreateObject("Excel.Application")
CommonEnd:
Exit Sub
EndOfSub:
Err.Description = "Error occured during launch Excel application (class ExcelClass)"
ShowErrorMessage
End Sub
Private Sub Class_Terminate()
If Not gExcelAppLaunched Then
Set gCurrentSheet = Nothing
Set gCurrentWorkbook = Nothing
gExcelApp.Application.Quit
Set gExcelApp = Nothing
End If
End Sub
Public Sub ShowErrorMessage()
If Err.Number <> 0 Then MsgBox Err.Description
Err.Clear
End Sub
Public Sub Visible()
If Not gExcelApp.Visible Then gExcelApp.Visible = True
End Sub
Ensuite tu utilises dans un module classique :
Sub FormatResultsFile(aFileName As String)
Dim lExcel As MSExcel_Class
Dim lWorkbook As Workbook
Dim lTabCount As Long
Set lExcel = New MSExcel_Class
'lExcel.Visible
Set lWorkbook = lExcel.gExcelApp.Workbooks.Open(aFileName)
For lTabCount = 1 To 7
lWorkbook.Sheets(lTabCount).Activate
lWorkbook.Sheets(lTabCount).Range(lWorkbook.Sheets(lTabCount).Cells(1, 1), lWorkbook.Sheets(lTabCount).Cells(1, lWorkbook.Sheets(lTabCount).UsedRange.Columns.Count)).Select
DrawGridBorder lExcel
DrawFrameBorder lExcel
lExcel.gExcelApp.Selection.Interior.ColorIndex = 15
lExcel.gExcelApp.Selection.Interior.Pattern = xlSolid
lExcel.gExcelApp.Selection.Font.Bold = True
lExcel.gExcelApp.Selection.HorizontalAlignment = xlCenter
lExcel.gExcelApp.Selection.VerticalAlignment = xlBottom
lExcel.gExcelApp.Selection.WrapText = False
lExcel.gExcelApp.Selection.Orientation = 0
lExcel.gExcelApp.Selection.ShrinkToFit = False
lExcel.gExcelApp.Selection.MergeCells = False
lWorkbook.Sheets(lTabCount).Range("A1").Select
lWorkbook.Sheets(lTabCount).Range(lWorkbook.Sheets(lTabCount).Cells(2, 1), lWorkbook.Sheets(lTabCount).Cells(lWorkbook.Sheets(lTabCount).UsedRange.Rows.Count, lWorkbook.Sheets(lTabCount).UsedRange.Columns.Count)).Select
DrawGridBorder lExcel
DrawFrameBorder lExcel
lWorkbook.Sheets(lTabCount).Range("A1").Select
lWorkbook.Sheets(lTabCount).Cells.EntireColumn.AutoFit
Next
lWorkbook.Sheets(1).Activate
lWorkbook.Sheets(1).Range("A1").Select
lWorkbook.Close True
Set lExcel = Nothing
End Sub
Voila si ca peux t'aider...
DaNot
un Libre ouvert à la source...