问题描述
我是VBA的新手,所以我在excel列中有一个文档列表(扩展名为.pdf,.docx等)。我想做的就是将列表中的所有文档从源文件夹复制到目标文件夹。
我已经尝试了一些代码,但是它可以复制文件夹中的所有文件而不是列表中的文件(文档列表仅在B3:B10中)。
任何帮助都很感激。
谢谢。
Sub copyfile()
Dim r As Range
Dim Jajal As Range
Dim sourcePath As String,DestPath As String,FName As String
sourcePath = "C:\Users\"
DestPath = "H:\Users\"
For Each r In Range(Sheet6.Range("B3"),Sheet6.Range("B10")) 'the list document is in the sheet6 B3:B10
FName = Dir(sourcePath & r)
'Loop while files found
Do While FName <> ""
'Copy the file
FileCopy sourcePath & FName,DestPath & FName
'Search the next file
FName = Dir()
Loop
Next
End Sub
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)