MS Access 宏执行更新查询并将文件从一个文件夹移动到另一个文件夹

MS Access Macro to perform an update query and move file from one folder to another

我有下面的代码附加到我数据库中标记为 "Checks" 的 table,但是,它将文件移动到 "Documents",我希望它移动到文件夹"C:\Users\User1\Desktop\TEst\Completed"

Sub Import_Multi_Excel_Files()

Dim InputFile As String  
Dim InputPath As String

InputPath = "C:\Users\User1\Desktop\TEst\Work\"  
InputFile = Dir(InputPath & "*.xls")

Do While InputFile <> ""  
    If InputFile Like "zz*" Then  
    Else  
        DoCmd.TransferSpreadsheet acImport, , "Checks", InputPath & InputFile,   True '< The true is for column headers  
        Name InputPath & InputFile As "Completed" & InputFile  
    End If  
    InputFile = Dir  
Loop  

End Sub

我可以通过更改

来解决这个问题
Name InputPath & InputFile As "Completed" & InputFile

Name InputPath & InputFile As InputPath & "Completed" & InputFile

我必须在 as 之后添加 InputPath。这现在将文件保存在同一文件夹中,但名称中包含 completed,因此无法再次导入。