I'm trying to write code to have Access close a spreadsheet in Excel that Access just exported. However, I keep throwing an error that tells me my table does not exist even though I'm STARING STRAIGHT AT IT! Very frustrating. All help is greatly appreciated. Thanks.
Private Sub Command12_Click()
DoCmd.SetWarnings False
Const xlFileName As String = "\\ct13nt003\mfg\SMT_Schedule_Files\SMT Line Progress Files\Test\SMT2Updated.xlsx"
Dim xlapp As Object
Dim wb As Object
Set xlapp = CreateObject("Excel.Application")
Set wb = xlapp.workbooks.Open(xlFileName)
'Delete Existing File First; then create new
On Error Resume Next
Kill xlFileName
On Error GoTo 0
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "SMT4Export", xlFileName, True
wb.Close savechanges:=False
Set wb = Nothing
Set xlapp = Nothing
DoCmd.SetWarnings True
End Sub