VBA- 拷贝文件夹下的所有文件到一个新的文件夹下

时间:2025-02-07 14:43:46

把代码中Path下的文件复制到afterPath目录下

Sub copyFiles(Path As String, afterPath)
	'Path:原文件夹路径;afterPath:目标文件夹路径
    Dim Spath As String
    '下边的我自己也不是很理解,但是效果达成是莫得问题的......
    Set fs = CreateObject("")
    Spath = Dir(Path, vbDirectory)
    Do While Len(Spath)
        If Spath <> "." And Spath <> ".." Then
            fs.CopyFolder Path, afterPath
            Spath = Dir()
        End If
    Loop
End Sub

相关文章