Hey, looking to take a copy of a folder before I update it and save a copy of it under a different name. Used Ron De Bruins guide as a start but I'm getting a Runtime error 70, permission denied error on the second to last line, see my code below.
Sub BackupOwnershipFiles()'This example move the folder from FromPath to ToPath. If MsgBox("Are you sure you'd like to create a back up of the ownership files?", vbYesNo) = vbNo Then Exit Sub Else End If Dim FSO As Object Dim FromPath As String Dim ToPath As String yyyy = Year(Now) mm = Format(Month(Now), "00") dd = Format(Day(Now), "00") FromPath = "S:\Regional Planners Product Ownership\Manager_Ownership_Files_" '<< Change ToPath = "C:\Users\name\Documents\Manager Ownership Backups\" & mm & "_" & dd & "_" & yyyy '<< Change 'Note: It is not possible to use a folder that exist in ToPath If Right(FromPath, 1) = "\" Then FromPath = Left(FromPath, Len(FromPath) - 1) End If If Right(ToPath, 1) = "\" Then ToPath = Left(ToPath, Len(ToPath) - 1) End If Set FSO = CreateObject("scripting.filesystemobject") If FSO.FolderExists(FromPath) = False Then MsgBox FromPath & " doesn't exist" Exit Sub End If If FSO.FolderExists(ToPath) = True Then MsgBox ToPath & " exist, not possible to move to a existing folder" Exit Sub End If FSO.MoveFolder Source:=FromPath, Destination:=ToPath 'THIS IS WHERE THE ERROR IS MsgBox "The folder is moved from " & FromPath & " to " & ToPath End Sub




Reply With Quote