I have routine that I'd like to copy all the file and paste to anther folder. Below is what I have so far. For testing purpose, I've left all the debug.print statement in. For this particular folder, I know there are two files in the folder I'm testing, one is a .pdf, and the other is a .txt. This routine seems to only grab the first file in the folder, which is the pdf. As it loops, it does not seem to recognize the .txt file as strFileName = "". I'd appreciate any help you can provide.
Code:
strFileName = Dir$(strCurrentPdfFolder & "*") Do While strFileName <> ""
Debug.Print "Current pdf folder: " & strCurrentPdfFolder
strCurrentFolderAndFile = strCurrentPdfFolder & strFileName
Debug.Print "Current Folder and File: " & strCurrentFolderAndFile
strFutureFolderAndFile = strFuturePdfFolder & strFileName
Debug.Print "Future folder and file name: " & strFutureFolderAndFile
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
If Dir(strFutureFolderAndFile) <> "" Then ' Checking if future file name exists
Debug.Print strFutureFolderAndFile
Kill strFutureFolderAndFile 'If existing file name exists
Call fso.CopyFile(strCurrentFolderAndFile, strFutureFolderAndFile, 0)
Else 'No file name exists
Call fso.CopyFile(strCurrentFolderAndFile, strFutureFolderAndFile, 0)
End If
strFileName = Dir$
Loop