beginner83
Registered User.
- Local time
- Today, 07:25
- Joined
- Jun 13, 2013
- Messages
- 11
Hi All,
On the click of a button on an Access form I create an Excel spreadsheet and write records to different tabs. This works fine if I don't touch Excel while it's running. If I close the excel sheet being created while it's running, if I try and click the button on the Access form to start the process again, it throws an error. Even when the spreadsheet successfully completes and I save and close it, if I click the button again on the Access form it won't work. I've read that this is something to do with the instance of excel that has been creating my spreadsheet isn't closed but I don't know how to close this in my code. I've created an instance of Excel..
I've tried using xl.Application.Quit, that closes the instance of Excel but when I click the button on the form again it won't work and the only way to make it work is to close the database and open it again.
Does anyone know how to close Excel??? :banghead:
Thanks in advance
On the click of a button on an Access form I create an Excel spreadsheet and write records to different tabs. This works fine if I don't touch Excel while it's running. If I close the excel sheet being created while it's running, if I try and click the button on the Access form to start the process again, it throws an error. Even when the spreadsheet successfully completes and I save and close it, if I click the button again on the Access form it won't work. I've read that this is something to do with the instance of excel that has been creating my spreadsheet isn't closed but I don't know how to close this in my code. I've created an instance of Excel..
Code:
Dim xl As New Excel.Application
Dim wkbk As Excel.Workbook
..
..
Set wkbk = xl.Workbooks.Add
With wkbk
..
..
End With
I've tried using xl.Application.Quit, that closes the instance of Excel but when I click the button on the form again it won't work and the only way to make it work is to close the database and open it again.
Does anyone know how to close Excel??? :banghead:
Thanks in advance