2021年5月1日星期六

fastest way to copy files/folders vba

I've written a recursive script with a couple of if statements to append all files/folders in in vba using FSO but it takes forever, and I'm looking for other methodologies, or faster ways to append files. Is using the DIR or Call shell a faster way? Any reasoning would be appreciated.

Dim SourceFolder As String Const DestinationFolder As String = "C:\Users\FolderX

Dim copyfolders(3) As String  copyfolders(0) = "C:\Users\FolderA"  copyfolders(1) = "C:\Users\FolderB"  copyfolders(2) = "C:\Users\FolderC"  copyfolders(3) = "C:\Users\FolderD"      For i = 0 to 3    Sourcefolder= copyfolders(i)  backupfiles sourcefolder, destinationfolder    Next i    Mgsbox "Done"    End sub  Sub backupfiles (Sourcefolder as string, Destinationfolder As string)      dim FSO as filesystemobject  dim oFiles as File  dim oFolder as Folder    set fso = new filesystemobject    if not "FSO.folderexists(Destinationfolder) Then FSO.Createfolder (destinationFolder)" then    For each oFile in FSO.Getfolder(sourcefolder).Files    IF fso.getextensionname(ofile.path) <> "pdf" Then    FSO.copyfile ofile.path, destinationfolder & "\" & oFile.Name    Else      End if  
https://stackoverflow.com/questions/67352238/fastest-way-to-copy-files-folders-vba May 02, 2021 at 09:25AM

没有评论:

发表评论