本帖最后由 猪兜鸿 于 2015-9-29 13:48 编辑
回复 6# pcl_test
解决问题了,谢谢斑竹。
我直接在excel里写VBA,贴上我的代码:- Sub 测试()
- Dim fso, n As Long, m As Long
- Set fso = CreateObject("scripting.filesystemobject")
- Set WshShell = CreateObject("wscript.shell")
- n = 0
- m = 0
- Do
- n = n + 1
- Kpath = "C:\Documents and Settings\admi\桌面\测试\报关单\" & Sheet1.Cells(n, 1).Value
- If fso.folderExists(Kpath) Then
- spath = "C:\Documents and Settings\admin\桌面\测试\文件夹\" & Sheet1.Cells(n, 2).Value & "\"
- fso.CopyFolder Kpath, spath
- fso.GetFolder(Kpath).Delete (True)
- Else
- m = m + 1
- Sheet1.Cells(m, 3).Value = Sheet1.Cells(n, 1).Value
- End If
- Loop Until Sheet1.Cells(n + 1, 1).Value = ""
- End Sub
复制代码
|