I have a procedure where I write a subform to an excel spreadsheet. The procedure works fine but after I have ran it and then try to open the spreadsheet I get a message that is in use. How do I get the lock off of the spreadsheet after my procedure runs? This is what I have:
Private Sub Command6_Click()
Dim oXL As Excel.Application
Dim oWkb As Excel.Workbook
Dim oWks As Excel.Worksheet
Dim rstSubForm As DAO.Recordset
Dim iRow As Integer
Set oXL = CreateObject("Excel.Application")
Set oWkb = oXL.Workbooks.Open("C:\Documents and Settings\weimha\My Documents\WO Notes\Object Log Project\Work Order Maintenance Log.xls")
Set oWks = oWkb.Sheets(1)
' write to spreadsheet
oXL.Visible = True
Set oWks = Nothing
Set oWkb = Nothing
Set oXL = Nothing
End Sub
Private Sub Command6_Click()
Dim oXL As Excel.Application
Dim oWkb As Excel.Workbook
Dim oWks As Excel.Worksheet
Dim rstSubForm As DAO.Recordset
Dim iRow As Integer
Set oXL = CreateObject("Excel.Application")
Set oWkb = oXL.Workbooks.Open("C:\Documents and Settings\weimha\My Documents\WO Notes\Object Log Project\Work Order Maintenance Log.xls")
Set oWks = oWkb.Sheets(1)
' write to spreadsheet
oXL.Visible = True
Set oWks = Nothing
Set oWkb = Nothing
Set oXL = Nothing
End Sub