Same problem but not yet solved
I have the same problem and read almost al the posts about it (lots of people with the same problem). I think it is stange that somany people have this problem, but I've not yet read a 100% solution.
Your problem seems to be the most simular to mine, because it also occursin a Selection statement.
Here is a part of my code:
Public Sub Test()
Dim wBook1 As Workbook
xls_file = frmMaakpro.txtFile.Text
Dim appExcel1 As Application
Set appExcel1 = CreateObject("Excel.Application")
Set wBook1 = appExcel1.Workbooks.Open(xls_file)
appExcel1.Visible = True
wBook1.ActiveSheet.Range(wBook1.ActiveSheet.Cells(3, 1), wBook1.ActiveSheet.Cells(10, 3)).Select
'Next line the error will occur
appExcel1.Selection.Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'--ending EXCEL
wBook1.Save
wBook1.Close
appExcel1.Workbooks.Close
appExcel1.Quit
Set appExcel1 = Nothing
Set wBook1 = Nothing
End Sub
I think I closed everything, and the first time I run this code, everything works fine. But the second time(without exiting my program) my program crashes on the Selection.Sort line : error 1004.
I think the error occurs because Excel is still active (Task Manager), but I cannot seem to Quit it.
When I close my project, excel also closes
Hope you could maybe try this code and maybe add or delete a few lines, so it will work well.
(Maybe I have to 'unselect' my Selection???, but how)
Thanks in advance
John