I am having some issues with the below piece of code. The data exports fine from access to excel, however, when I go to view the excel file it says its locked for editing. Does anyone know why?
Public Sub ExportFiles()
Dim X As Object
Dim Y As Object
Dim XL As Object
Dim rs As Recordset
Set X = CreateObject("Excel.Application")
Set Y = X.Workbooks.Open("\\POISE\Data\LCS\DomGroup\ICE NMW Performance and DQ\Tasking MI\2014-15\Production Pack Template\OFFICIAL SENSITIVE Tasking Team Production Pack.xlsx")
Set XL = Y.Sheets("Tasking Records")
Set rs = CurrentDb.OpenRecordset("ALL")
XL.Range("A2").CopyFromRecordset rs
Y.SaveAs "\\POISE\Data\LCS\DomGroup\ICE NMW Performance and DQ\Tasking MI\2014-15\Production Pack Output\" & "Tasking " & "Week " & Format(FiscalWeek, "w") & Format(Date, "yyyymmdd") & ".xlsx"
X.Visible = False
Set X = Nothing
Set Y = Nothing
Set XL = Nothing
rs.Close
Set rs = Nothing
End Sub