Function LocalizeFile(filePath As String, saveDir As String) As Boolean
On Error GoTo LocalizeFile_Err
' Copy file to a directory on the local machine if it does not yet exist locally
' saveDir should have a '\' at the end
Dim fileName As String
fileName = saveDir & FileNameFromPath(filePath)
If Dir(fileName) > vbNullString Then
' File already exists
' Put code to handle this case here if necessary
End If
FileCopy filePath, fileName
SetAttr fileName, vbNormal
LocalizeFile = True
Exit Function
LocalizeFile_Err:
MsgBox "Error: " & Err.Description & ". Ensure that the file is not currently open."
End Function
This function copies a file to a specified directory, which should already exist. Use this in a multi-user encironment, where a template file is available on a server, and needs to be copied to a local directory for further manipulation.