I am trying to import a file from Excel into Access via a command button on a form. I keep getting the following error:
Run-time error '3274':
External table is not in the expected format.
However if I run it with the Excel File open, it works perfectly.
Any suggestions on how to do it without having the file open?
p.s. See attached code for my command button
Private Sub cmdImport_Click()
If IsNull(Me.txtFileName) Or Len(Me.txtFileName & "") = 0 Then
MsgBox "please select the excel file"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Import", Me.txtFileName, True