导入 excel 以使用通配符访问

Importing excel to access with wildcards

我正在尝试将 excel 文档导入到 table 中,该文档在访问

中尚不存在

我正在使用以下代码:

' Import Hourly stats
        DoCmd.TransferSpreadsheet transfertype:=acImport, SpreadsheetType:=10, _
        tablename:="Hourly", FileName:="C:\Filename\folder\stats* _
        Hasfieldnames:=True, Range:="AgentActivity!"

我将通配符 * 放在文件名的末尾,因为文件名的后半部分每隔一小时左右就会发生变化。

当我 运行 代码时,我得到这个错误:

The Microsoft access database engine could not find the object. Make sure the object exists and that you spell its name and the path name correctly

感谢任何帮助。

看起来您只是缺少文件名末尾的结束引号。

' Import Hourly stats
    DoCmd.TransferSpreadsheet transfertype:=acImport, SpreadsheetType:=10, _
    tablename:="Hourly", FileName:="C:\Filename\folder\stats*", _
    Hasfieldnames:=True, Range:="AgentActivity!"