|
阿柔 发表于 2014-5-26 11:20
老师您好,今天试用修改众多文件夹名时,出现了错误提示。
试了一下,修改1--49或1--52时,很正常。多一 ... - Sub demo1()
- Dim strPath$, strName$
- Dim l%
- Dim strNewName$
- strPath = ThisWorkbook.Path & Application.PathSeparator
- strName = Dir(strPath & "*.*", vbDirectory)
- Do While Len(strName)
- strNewName = ""
- If (GetAttr(strPath & strName) And vbDirectory) = vbDirectory Then
- l = Val(strName)
- If l Then
- strNewName = Replace(Cells(1, l).Address(False, False), 1, "")
- Name strPath & strName As strPath & strNewName
- End If
- End If
- strName = Dir
- Loop
- MsgBox "重命名完成"
- End Sub
复制代码 直接用取巧的方法,最多可以到16384。
|
|