VBA 实现批量excel文件复制

对于每天要将文件复制到其他多个路径

1 在test文件下新建3个子文件夹  test1,test2,test3
2 在test1下新建li01.xlsx,li02.xlsx,hua01.xlsx,hua02.xlsx和文件夹li1
3 新建宏,并制作按钮键
4 fs.copyfile "文件路径","目标路径",True(是否覆盖重名文件)
  fs.copyfolder "文件夹路径","目标路径",True(是否覆盖重名文件)

Sub copy()

Set fs = CreateObject("Scripting.FileSystemObject")
  

fs.copyfolder "E:\test\test1\li1",  "E:\test\test3\", True '复制文件夹到指定目录

fs.copyfile "E:\test\test1\hua*.xlsx", "E:\test\test3\", True   '复制文件到指定目录

fs.copyfile "E:\test\test1\li*.xlsx", "E:\test\test3\", True   '复制含通配符的文件到指定目录



msgbox("well done!")  '运行成功提示

End Sub

posted @ 2016-05-12 12:26  li_volleyball  阅读(2014)  评论(0编辑  收藏  举报