I have the following code which loops thru cells until the condition is true. When the condition is true, I branch out of the loop to close the Excel file. The err.number is 0 in all events, but the file does not be closed upon checking the task manager.
Set oXl = CreateObject("Excel Application")
oXl.Workbooks.Open(Myfile)
Do Until x = " " or x_cnt = 100
If oXl.ActiveCell.Offset(R, C).Value <> Empty Then
x = oXl.ActiveCell.Offset(R, C).Value
x_cnt = x_cnt + 1
Else
Goto Exit1
End If
......
Loop
Exit1:
....
Msgbox (err.number) is 0 entering these next statements
oXl.Application.Quit
Msgbox (err.number) still 0
Set oXl = Nothing
Msgbox (err.number) still 0
I've even tried oXl.Close(Myfile) and when I leave this statement as a part of the code, oXl.ThisWorkBook.Saved = True, err.number = 91. I've tried False as well, but still get err 91. File is task manager remains open.