Excel File Locks

I developed an application in Access that also ties into Excel, my Access app gets data from Excel and updates 12 tables, then allows the user to select a date range and it dumps out to 12 excel files, refreshes excel and the excel app then has 12 data connections to those files for doing graphs etc.   I open both Excel and Access and run the access vb and it all works fine but if I rerun it a second time it fails on the export to excel and it says the files are open by another application....So I guess the excel files get locked by excel when I refresh the data link, is there a way to temporarily break that link (lock) so I can update those excel files?
INSCNOCAsked:
Who is Participating?
 
gowflowCommented:
You need to ensure in your code that all instances of excel that are opened are killed and all workbooks that were opened are also killed something like

Dim oApp as Excel.Application
Dim wb as workbook
....
your code


.. before closing
wb.close
Set wb = Nothing
Set oApp = Nothing

gowflow
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.