1
I have a folder where I keep data that needs to be updated daily. To not miss the history copy this folder and paste elsewhere. But, after copying and pasting the folder, I need to rename it with the current date to not have folders with the same name.
Sub faz_backup()
Dim newName As String
CopiarArq "C:\Users\leandro.lazari\Desktop\Dados MegaWhat\Dados",
"C:\Users\leandro.lazari\Desktop\Dados MegaWhat\Histórico"
Data = DateSerial(Year(Now), Month(Now), Day(Now))
newName = "C:\Users\leandro.lazari\Desktop\Dados MegaWhat\Histórico\Dados"
Name "C:\Users\leandro.lazari\Desktop\Dados MegaWhat\Histórico\Dados"
As newName & Data
End Sub
I did so. The code copies and pastes the folder, but an error appears saying that the file was not located. However, the address is correct
Daniel, good morning! I made the changes you said and tried to perform a few times. Sometimes it works and sometimes the error appears: "Run-time error '75': Path/file access error". Some reason for this?
– Leandro Lazari
On which line the error occurs?
– danieltakeshi
Where renames the folder, in the name line "..." as "...."
– Leandro Lazari
Well I can’t reproduce this error, but do you have any user restrictions? Is it a company computer? You may not be allowed access or the Path is incorrect. But if you used the full code that checks for the folder, the problem would probably be permission.
– danieltakeshi
If the user does not have access to make some changes, mainly on the server... IT can help you with access restrictions.
– danieltakeshi
Got it! But if I didn’t have access permission I wouldn’t have trouble doing it manually either?
– Leandro Lazari
Behold this article and check that the folder is not read-only. And your account user permissions. Or you may be entering a wrong path, such as by inserting the
\
at the end of the newname string– danieltakeshi
Daniel, you didn’t change the outcome.
– Leandro Lazari
Or you may be entering a wrong path, for example by inserting the bar at the end of the newname string. But check the permissions.
– danieltakeshi
Daniel, I was able to fix it! The problem was time. The code tried to rename the file before it appeared in the folder. I put a Sleep remote and it worked.
– Leandro Lazari