Can someone look at this code and tell me why it won't release the database after it fills the flexgrid and I close excel. I have tried everything.
vb Code:
Dim xapp As Excel.Application
Dim xsheet As Excel.Worksheet
Dim xlWB As Excel.Workbook
Set xapp = New Excel.Application
Set xlWB = xapp.Workbooks.Open("C:\Program Files\Denali\Databases\Databasesloc.xls")
Excel.Application.Visible = False
Clipboard.Clear
Set xsheet = xapp.Worksheets(1)
With xsheet
.UsedRange.Copy
End With
With MSFlexGrid1
.Redraw = False
.row = 0
.Col = 0
.RowSel = .Rows - 1
.ColSel = .cols - 1
.clip = Replace(Clipboard.GetText, vbNewLine, vbCr)
.Col = 1
.Redraw = True
End With
xapp.DisplayAlerts = False
Clipboard.Clear
MSFlexGrid1.Rows =xapp.ActiveWorkbook.ActiveSheet.UsedRange.Rows.count + 1
'Trying to close Excel here
Set xsheet = Nothing
xlWB.Close SaveChanges:=False
Set xlWB = Nothing
xapp.Quit
Set xapp = Nothing
Excel.Application.Quit