|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
层级判断。。。- Sub ykcbf() '//2024.8.14
- p = ThisWorkbook.Path & ""
- With Application.FileDialog(msoFileDialogFilePicker)
- .InitialFileName = p
- .Title = "请选择要复制的文件"
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "All Files", "*.*"
- If .Show Then f = .SelectedItems(1) Else Exit Sub
- End With
- getfds p, 1, f
- MsgBox "OK!"
- End Sub
- Sub getfds(p, level, f)
- Set fso = CreateObject("Scripting.FileSystemObject")
- For Each fd In fso.GetFolder(p).SubFolders
- If level = 3 Then
- fso.CopyFile f, fd.Path & ""
- ElseIf level < 3 Then
- getfds fd.Path, level + 1, f
- End If
- Next fd
- Set fso = Nothing
- End Sub
复制代码
|
|