简体   繁体   中英

Importing excel to access with wildcards

I am trying to import an excel document to a table that doesn't yet exist in access

I am using the following code:

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

I have put the wildcard * at the end of the filename because the end half of the filename changes ever hour or so.

When I run the code I get this error:

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

Any help is appreciated.

Looks like you are just missing the closing quote at the end of the filename.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM