我正在尝试根据文件夹中包含一堆文件的日期找到一个特定文件并将其移动到另一个文件夹,听起来很简单吗?好吧,我正在接受
拒绝权限
错误,我不确定我的代码是否错误或是否是文件访问问题。任何帮助,将不胜感激!这是我的代码:
Sub MoveFiles()
Dim myValn As String
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim myDate3 As String
Dim Wmsn As String
Set ws = ThisWorkbook.Worksheets("UPLOADER")
Set ws2 = ThisWorkbook.Worksheets("VARIABLES")
myName = ws2.Range("B2").Value
myValn = ws2.Range("B1").Value
myDate3 = Format(Date, "mm-dd-yyyy")
Wmsn = "WMS_36196_PROD_" & myDate3 & ".csv" 'trying to find the file to move with the current date in it's name
'example filename is WMS_36196_PROD_12-21-2017.csv
'source path below
FileCopy "\\Rdcicgtcuwd01p\app_log\36196_WMS\" & Wmsn, _
"\\olscmesf003\gcm_emea\TCU_REPORTS\APPS\Reports\Regional\Workflow Management System\2017\" 'destination path
End Sub
答案 0 :(得分:1)
我已根据@Alex K的有用建议修改了代码,现在效果很好。问题是,我没有为目的地指定文件名,仅针对原点。谢谢你的解决!
正确的代码是:
channel