M
Miked
hello all!
I am asking a somewhat familiar question, but the reponses I've seen on
the group don't quite answer the question. Like Most, I'm piping
through to an excel applicatio to handle some data. here are my
opening lines:
Set xlApp = CreateObject("excel.application")
xlApp.Visible = False
xlApp.DisplayAlerts = False
Set xlWB = xlApp.Workbooks.Add
Set xlWS = xlWB.Worksheets(1)
xlWB.SaveAs (filename)
Set db = OpenDatabase(filename, False, False, "Excel 8.0")
Set rst1 = db.OpenRecordset("datasheet")
Then I do some processing. I want to close the excel WB, WS and db, as
well as the application, so I invoke what I thought to be pretty
standard code:
'delete the existing file
If IsNothing(xlWB) = False Then
xlWB.Close False
Set xlWB = Nothing
End If
If IsNothing(db) = False Then
db.Close
Set db = Nothing
End If
If IsNothing(xlApp) = False Then
xlApp.Application.Quit
'xlApp.Application.Close
Set xlApp = Nothing
End If
'kill the recordset as well
If IsNothing(rst1) = False Then
rst1.Close
Set rst1 = Nothing
End If
'check to see if the file exists first
filename = "c:\FSDdata.xls"
check = Dir(filename)
If Len(check) > 0 Then
VBA.Kill (filename)
End If
This seems to work fine, but on the next go around, when I try and get
the same code, I get a permissions error on "filename". I look in the
task manager, and excel is still running in the background. How come
the lines above don't work? For the xlApp, I've tried:
xlApp.Close
xlApp.application.close
xlapp.quit
And nothings works! Again, the goal is to get the app that is working
in the background to be gone, so that I don't get a permissions
violation when accessing the same file.
Thanks so much in advance for your help!
Mike D
I am asking a somewhat familiar question, but the reponses I've seen on
the group don't quite answer the question. Like Most, I'm piping
through to an excel applicatio to handle some data. here are my
opening lines:
Set xlApp = CreateObject("excel.application")
xlApp.Visible = False
xlApp.DisplayAlerts = False
Set xlWB = xlApp.Workbooks.Add
Set xlWS = xlWB.Worksheets(1)
xlWB.SaveAs (filename)
Set db = OpenDatabase(filename, False, False, "Excel 8.0")
Set rst1 = db.OpenRecordset("datasheet")
Then I do some processing. I want to close the excel WB, WS and db, as
well as the application, so I invoke what I thought to be pretty
standard code:
'delete the existing file
If IsNothing(xlWB) = False Then
xlWB.Close False
Set xlWB = Nothing
End If
If IsNothing(db) = False Then
db.Close
Set db = Nothing
End If
If IsNothing(xlApp) = False Then
xlApp.Application.Quit
'xlApp.Application.Close
Set xlApp = Nothing
End If
'kill the recordset as well
If IsNothing(rst1) = False Then
rst1.Close
Set rst1 = Nothing
End If
'check to see if the file exists first
filename = "c:\FSDdata.xls"
check = Dir(filename)
If Len(check) > 0 Then
VBA.Kill (filename)
End If
This seems to work fine, but on the next go around, when I try and get
the same code, I get a permissions error on "filename". I look in the
task manager, and excel is still running in the background. How come
the lines above don't work? For the xlApp, I've tried:
xlApp.Close
xlApp.application.close
xlapp.quit
And nothings works! Again, the goal is to get the app that is working
in the background to be gone, so that I don't get a permissions
violation when accessing the same file.
Thanks so much in advance for your help!
Mike D