UnsolvedCoding
Technical User
Hey all - this is something of a new one for me.
It was requested that I hook in a few changes to an existing app. Basically they want to use Excel to open a folder, check if a MDB is present (Source folder) move it to a different folder (Destination folder). The MDB name may exist in the destination folder already at which point the MDB in the destination folder needs to be renamed.
I have found several ways to count folders in files - example
Sub Demo()
MsgBox FileCountA("C:\Test\")
MsgBox FileCountB("C:\Code Library\VBA Code\")
End Sub
Function FileCountA(Path As String) As Long
Dim strTemp As String
Dim lngCount As Long
strTemp = Dir(Path & "*.*")
Do While strTemp <> ""
lngCount = lngCount + 1
strTemp = Dir
Loop
FileCountA = lngCount
End Function
Function FileCountB(Path As String) As Long
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject").GetFolder(Path)
FileCountB = objFSO.Files.Count
Set objFSO = Nothing
End Function
And there are several ways to count files ending in specific extensions. However I need to capture the names of the MDB's in an array, rename to duplicate and then copy the original from the source folder to the destination folder.
Ideas?
It was requested that I hook in a few changes to an existing app. Basically they want to use Excel to open a folder, check if a MDB is present (Source folder) move it to a different folder (Destination folder). The MDB name may exist in the destination folder already at which point the MDB in the destination folder needs to be renamed.
I have found several ways to count folders in files - example
Sub Demo()
MsgBox FileCountA("C:\Test\")
MsgBox FileCountB("C:\Code Library\VBA Code\")
End Sub
Function FileCountA(Path As String) As Long
Dim strTemp As String
Dim lngCount As Long
strTemp = Dir(Path & "*.*")
Do While strTemp <> ""
lngCount = lngCount + 1
strTemp = Dir
Loop
FileCountA = lngCount
End Function
Function FileCountB(Path As String) As Long
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject").GetFolder(Path)
FileCountB = objFSO.Files.Count
Set objFSO = Nothing
End Function
And there are several ways to count files ending in specific extensions. However I need to capture the names of the MDB's in an array, rename to duplicate and then copy the original from the source folder to the destination folder.
Ideas?