Opening and Closing Excel from Access in VBA
Posted on 2014-03-05
What's the best way to open Excel from an Access module and then close it?
My code exports some data to Excel and at the end I display the resulting workbook.
The problem is that the creates a new instance of Excel but I don't know how to close it.
Dim myXL As excel.Application
Set myXL = New excel.Application
'it then populates the workbook
myXL.Visible= True 'at the end
Set myXL = Nothing
The result in Excel is fine, but when the user closes Excel the instance remains as a process.
Can you help me with:
A better way to start Excel, especially if it's running
How to give the user the control of closing the instance/process?