【发布时间】:2016-02-03 00:10:05
【问题描述】:
尝试将数据从 Excel 文件 (vrtSelectedItem) 导入 Access 表 (MAF),但在 DoCmd 行上收到“类型不匹配”错误。
数据位于名为“For Export”的工作表中,但我不确定我是否正确指出了这一点。不过,可能还有其他东西。
此外,数据位于命名范围“ExportRange”中。是否可以使用名称而不是指定单元格?
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
Dim xl As Object
Dim wb As Object, ws As Object
'Dim data1 As Variant
'Select Excel file
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
.AllowMultiSelect = True
.Title = "Select one or more files"
.InitialFileName = InitPath
If .Show = True Then
Set xl = CreateObject("excel.application")
For Each vrtSelectedItem In .SelectedItems
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, MAF, vrtSelectedItem("For Export"), 0, "B1:B72"
Next
End If
End With
【问题讨论】: