I am currently developing a database which requires an Excel file of numeric data to be exported, but also with formatting of this data to 2 decimal places. I discovered that the best way to do this is to alter the export file itself using Access code after it has been created. However I am having trouble closing down Excel in the background after the changes. I open up the Worksheet, make the changes and then save and close it all down using the below code:
However when I then go to Windows Explorer and double click on the export file to view the data before closing down the database it does not open as it is still remaining open in the background invisibly. Once I exit the database this seems to close the invisible Excel down also and I can then open the file fine. Can anyone tell me how to shut down the invisible Excel and the file so that I can immediately open the file using windows explorer? The only extra reference I have used in the database is Microsoft Excel 8.0 Object Library.
Code:
'Save the workbook
oxlWorkbook.Save
'Close the workbook and quit the Excel application
oxlWorkbook.Close False
oxlApp.Quit
'Clear vars
Set oxlWorksheet = Nothing
Set oxlWorkbook = Nothing
Set oxlApp = Nothing