I'm using the following code to import data from Excel to Access:
I have a named range within the excel file titled MatrixTable and from looking on the MSDN website, I should be able to use the name of the range. I don't get any errors, but no data gets transferred. tblMatrix is a pre-existing table. I'm not sure what to try at this point.
Code:
Public Sub ImportMatrix()
Dim db As DAO.Database
On Error GoTo Error_Handler
Set db = CurrentDb
DoCmd.Hourglass True
db.TableDefs.Refresh
DoCmd.TransferSpreadsheet _
TransferType:=acImport, _
SpreadsheetType:=acSpreadsheetTypeExcel9, _
TableName:="tblMatrix", _
FileName:="\\ftcbank1\docs\sschrock\My Documents\Database Stuff\FTC Morgage Rate Database\Mortgage Matrix.xls", _
HasFieldNames:=False, _
Range:="MatrixTable"
db.TableDefs.Refresh
Exit_Procedure:
Set db = Nothing
DoCmd.Hourglass False
Exit Sub
Error_Handler:
'Call ErrorMessage(Err.Number, Err.Description, "modImport: ImportMatrix")
'TSCs_ReportUnexpectedError "ImportMatrix", "modImport", "Custom info"
Resume Exit_Procedure
Resume
End Sub
Comment