Every x days I have to "archive" a ton of databases by copy/pasting them into an archive folder on a shared network. This task was recently assigned to me and the previous party was doing this by hand over the course of an hour (at least). I've automated it but am getting tripped up when my code is trying to copy databases that are currently open elsewhere.
I popped some dynamic file paths in an Excel workbook and used the following code to automate this task:
Sub archive()
'On Error Resume Next
Dim i As Integer
For i = 2 To 56
FileCopy Sheets("Sheet2").Cells(i, 1), Sheets("Sheet2").Cells(i, 2)
Next i
End Sub
I know it's not as pretty as it could be, but that's not my problem. My problem is that at any given time, multiple users are in at least one of the dozens of database instances I need to make a copy of, and apparently Windows doesn't allow copy of an open file (?) via VBA. I can go to the specified folder and manually do it, though, which is somehow safer it would seem..
Anyways, is there a good solution here other than me manually copying the databases that are open when I run my macro? Can I force the copy somehow?