|
szqhb 发表于 2011-11-1 08:45
zhao老师的代码好好,人忒好!!热心。
能否将代码修改一下,取文档的某几个字符创建文件夹(比如:前3个 ...
Sub Macro1()
Dim MyPath$, MyName$, DestinationPath$, arr(), i&, m&
MyPath = ThisWorkbook.Path & "\"
MyName = Dir(MyPath & "*.doc")
Do While MyName <> ""
m = m + 1
ReDim Preserve arr(1 To m)
arr(m) = MyName
MyName = Dir
Loop
For i = 1 To m
DestinationPath = MyPath & Mid(arr(i), 3, 4) '取文档的第3至6个
If LenB(Dir(DestinationPath, 16)) = 0 Then MkDir DestinationPath
FileCopy MyPath & arr(i), DestinationPath & "\" & arr(i)
Next
MsgBox "ok"
End Sub
|
|