T
tricks via AccessMonster.com
I'm trying to import data from excel using vba code. The excel file has
three columns, name weight,and team name. If I just go to file, get external
data, import everything works great. If I use the code below, the only
information that is imported is team name. The information in the other two
columns aren't imported. Here is the code I'm using:
Dim strDirectory As String, strFilter As String
Dim strFileName As String, strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
strDirectory = Left(strInputFileName, _
InStrRev(strInputFileName, "\"))
strFileName = Dir(strDirectory & "*.xls")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"Team_Roster", strInputFileName, True
Any help would be greatly appreciated.
three columns, name weight,and team name. If I just go to file, get external
data, import everything works great. If I use the code below, the only
information that is imported is team name. The information in the other two
columns aren't imported. Here is the code I'm using:
Dim strDirectory As String, strFilter As String
Dim strFileName As String, strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
strDirectory = Left(strInputFileName, _
InStrRev(strInputFileName, "\"))
strFileName = Dir(strDirectory & "*.xls")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"Team_Roster", strInputFileName, True
Any help would be greatly appreciated.