ajCopyFile function
Description
The ajCopyFile function copies a file from one location to another.
Syntax
ajCopyFile(source_file_path, destination_folder_path, [overwrite], [run_condition],[run_by_function_point_only])
Argument Name | Argument Type | Description |
---|---|---|
source_file_path (required) | String | The path of the file that is to be copied. Both the forward-slash (/) and backslash (\) are supported as the folder separator. |
destination_file_path (required) | String | The destination file path where the file will be copied to. It is optional to end with a slash. Both the forward-slash (/) and backslash (\) are supported as the folder separator. |
overwrite (optional) | Boolean | TRUE - a file with the same name is overwritten. FALSE - a file with the same name is not overwritten. Error #VALUE! would be returned. The default is FALSE. |
run_condition (optional) | Boolean | The function will run when the value is TRUE. Otherwise will not run. The default value is TRUE. |
run_by_function_point_only (optional) | Boolean | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Preview Function Point. If it equals TRUE, the function can be executed with Preview Function Point (AlchemyJ ribbon \ Preview Function Point) only. The default value is TRUE. |
The function will return:
1) Return Value: TRUE, #VALUE!
2) Return Type: Single Value / Multiple values (array formula)
Example
Example 1
=ajCopyFile("c:\source.txt", "c:\new_folder\")
If the source file and destination folder path exist, the function returns TRUE. The file will be copied to c:\new_folder
Example 2
=ajCopyFile("c:\no_such_file.txt", "c:\new_folder\")
If the source file does not exist, error #VALUE! would be returned.
Click here to download the use case workbooks for further reference.
## Error ScenariosIt will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will raise error for below scenario(s).
Error Scenario |
---|
Invalid source file path. |
Invalid destination file path. |
The file in the destination file path already exists. |
No authority to operate the file. |