Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1674|回复: 3

[已解决]请求赐教!移动文件中的文件

[复制链接]
发表于 2012-6-9 07:11 | 显示全部楼层 |阅读模式
求教,移动。.rar (43.06 KB, 下载次数: 58)
发表于 2012-6-9 11:14 | 显示全部楼层
  1. Sub ListSubFolder() 'MXG825 2012-6-9
  2. Dim strPath As String, strTmp As String
  3. Dim oldTmp As String, newTmp As String
  4. strPath = ThisWorkbook.Path & ""
  5. If Dir(strPath & "汇总", 16) = Empty Then '汇总文件夹是否存在
  6. MkDir strPath & "汇总" '建一个
  7. End If
  8. strTmp = Dir(strPath & "*", vbDirectory) '列出所有目录
  9. Do While strTmp <> "" '历遍全部文件夹
  10. '以vbDirectory属性来调用Dir时,不能连续地返回子目录,所以使用GetAttr来判断结果是否为目录
  11. If GetAttr(strPath & strTmp) And vbDirectory Then

  12. On Error GoTo NextTmp '防文件不存在 跳转词句
  13. If InStr(1, "汇总,提取.xls..", strTmp) = 0 Then '剔除 汇总文件夹 和提取 工作薄
  14. oldTmp = strPath & strTmp & "\汇总\汇总.xls" '原文件路径
  15. newTmp = strPath & "\汇总" & strTmp & ".xls" '新文件路径
  16. FileCopy oldTmp, newTmp '复制 重命名文件
  17. 'Debug.Print strPath & strTmp
  18. End If
  19. End If
  20. NextTmp:
  21. strTmp = Dir
  22. Loop
  23. End Sub
复制代码

回复

使用道具 举报

发表于 2012-6-9 14:47 | 显示全部楼层    本楼为最佳答案   
早上网络太卡 无法上传附件。。。现在补上! 求教,提取。.rar (55.87 KB, 下载次数: 265)

评分

参与人数 1 +1 收起 理由
松儿 + 1 很给力!

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2012-6-9 15:27 | 显示全部楼层
mxg825 发表于 2012-6-9 14:47
早上网络太卡 无法上传附件。。。现在补上!

正是,真好。谢谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-14 08:49 , Processed in 0.534675 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表