我无法将Excel文件导入Microsoft Acess

时间:2018-08-19 10:43:44

标签: excel ms-access

当我进入外部数据标签并选择 Excel 选项时,我可以从那里导出数据,但是不能导入。 我收到无法导入的表格 IMG1

2 个答案:

答案 0 :(得分:1)

enter image description here只需转到外部数据标签,然后在左上角有一个按钮“新数据源”。单击此按钮,然后选择“来自文件”,然后选择“ Excel”

答案 1 :(得分:0)

您可以使用VBA从多个Excel文件执行相同或更多操作,例如将数据导入Access。

Sub TryThis()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean

' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = False

' Replace C:\Documents\ with the real path to the folder that
' contains the EXCEL files
strPath = "C:\Documents\"

' Replace tablename with the real name of the table into which
' the data are to be imported
strTable = "tablename"

strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
      strPathFile = strPath & strFile
      DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
            strTable, strPathFile, blnHasFieldNames

' Uncomment out the next code step if you want to delete the
' EXCEL file after it's been imported
'       Kill strPathFile

      strFile = Dir()
Loop

End Sub