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
| Private Sub Command1_Click()
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ajout d'un classeur car à l'ouverture d'Excel il n'y a aucun classeur d'ouvert
appExcel.Workbooks.Add 'Ceci n'est nécessaire que si vous n'ouvrez pas un fichier existant
'Récupération du classeur par défaut
Set wbExcel = appExcel.ActiveWorkbook
'Récupération de la feuille par défaut
Set wsExcel = wbExcel.ActiveSheet
appExcel.Visible = True
'
'
'
' code
'
'
'
wbExcel.SaveAs Command1.Caption
wbExcel.Close
appExcel.Quit
Set wsExcel = Nothing
Set wbExcel = Nothing
Set appExcel = Nothing
End Sub |