|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 取名()
Dim a(), arr, i%, myPath$, mn$
With Application.FileDialog(4)
s = .Show
If s <> 0 Then
st = .SelectedItems(1)
Else
Exit Sub
End If
End With
myPath = st & "\"
myname = Dir(myPath, vbDirectory)
mn = ThisWorkbook.Name
Range("a2:a65536") = ""
Do While myname <> ""
If myname <> "." And myname <> ".." And myname <> mn Then
If (GetAttr(myPath & myname) And vbDirectory) = vbDirectory Then
i = i + 1
ReDim Preserve a(i)
a(i) = myname & "\"
Else
i = i + 1
ReDim Preserve a(i)
a(i) = myname
End If
End If
myname = Dir
Loop
k = 1
For j = 2 To i + 1
Cells(j, 1) = a(k) & MyWjName
k = k + 1
Next
[O1] = myPath
End Sub
Sub 改名()
myPath = [O1]
ma = [a65536].End(3).Row
For i = 2 To ma
Name myPath & Cells(i, 1) As myPath & Cells(i, 2)
Next i
End Sub
分两步呗、乱凑了一个以前的代码、先取文件夹下的文件名称 到表的A列 ,然后通过操作表格在B列改好对应的名称 然后用B列的名称去给文件命名。 |
|