Excel Spreadsheet Import Failing

P

PatK

Ok...I officially give up. I must be missing something so am asking if anyone
sees my bug here. When I get to the Docmd.TransferSpreadsheet, I get a 3011
error, saying the Jet database engine could not find object (the "Asset-Info"
worksheet). What am I missing here? The worksheet definitely exists and the
MsgBox's I have show me it is passing exactly what I want to the
transferspreadsheet command. Ideas?

Private Sub ImportExcel()
Dim sFname As String
Dim sWSheet As String
Dim sTable As String
Dim lngFlags As Long
Dim sFilter As String

sFilter = AddFilterItem(sFilter, "Excel Files (*.XLS)", "*.XLS")
sFname = CommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
sWSheet = "Asset-Info"
sTable = "tblAssetUpdate"
MsgBox sFname
MsgBox sWSheet
MsgBox sTable
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, sTable, _
sFname, True, sWSheet <<---this seems to be the problem

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top