|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
文件复制到桌面- Sub ykcbf() '//2024.5.17
- Dim fns As New Collection
- Set fso = CreateObject("Scripting.FileSystemObject")
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择文件夹"
- .InitialFileName = ThisWorkbook.Path & ""
- If .Show = -1 Then
- p = .SelectedItems(1) & ""
- End If
- End With
- p1 = CreateObject("Wscript.Shell").SpecialFolders("Desktop") & "\out"
- If Not fso.FolderExists(p1) Then fso.CreateFolder p1
- Set sh = ThisWorkbook.Sheets("操作台")
- Set ff = fso.GetFolder(p)
- getFiles ff, fns, fso
- ReDim brr(1 To 1000, 1 To 1)
- For Each f In fns
- m = m + 1
- brr(m, 1) = f(1)
- fso.CopyFile f(0), p1
- Next
- With sh
- .[h2:h1000] = ""
- .[h2].Resize(m, 1) = brr
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|