Okay I Know this is a problem already dealt with in a number of posts But I have Tried the solutions and Excel is still hanging when I try To close it.
If I open an Excel application and worksheet and then close with out doing anything to the sheet I have no problem and I can reopen and close as many times as I like without reseting my project.
However if I enter any data in the workbook, excel won't close properly. It looks like its closed but it is still open in taskmanager if I use Ctrl Alt del and I have To reset my project inorder to open excel again.
I have included two sets of code the first set is working, the second isn't. Someone please tell me why.
Thanks in advance for the advice.
Code:'code working
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Private Sub cmdClose_Click()
xlWkb.Close False
Set xlWkb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
Private Sub CmdTry_Click()
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWkb = xlApp.Workbooks.Add
'xlApp.DisplayAlerts = False
End Sub
Code://code not working
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Dim xlSht As Excel.Worksheet
Private Sub cmdClose_Click()
xlWkb.Close False
Set xlSht = Nothing
Set xlWkb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
Private Sub CmdTry_Click()
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWkb = xlApp.Workbooks.Add
Set xlSht = xlWkb.Worksheets("Sheet1"
Range("A1" = "You Did It"
'xlApp.DisplayAlerts = False
End Sub
If I open an Excel application and worksheet and then close with out doing anything to the sheet I have no problem and I can reopen and close as many times as I like without reseting my project.
However if I enter any data in the workbook, excel won't close properly. It looks like its closed but it is still open in taskmanager if I use Ctrl Alt del and I have To reset my project inorder to open excel again.
I have included two sets of code the first set is working, the second isn't. Someone please tell me why.
Thanks in advance for the advice.
Code:'code working
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Private Sub cmdClose_Click()
xlWkb.Close False
Set xlWkb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
Private Sub CmdTry_Click()
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWkb = xlApp.Workbooks.Add
'xlApp.DisplayAlerts = False
End Sub
Code://code not working
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Dim xlSht As Excel.Worksheet
Private Sub cmdClose_Click()
xlWkb.Close False
Set xlSht = Nothing
Set xlWkb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
Private Sub CmdTry_Click()
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWkb = xlApp.Workbooks.Add
Set xlSht = xlWkb.Worksheets("Sheet1"
Range("A1" = "You Did It"
'xlApp.DisplayAlerts = False
End Sub