Hello all,
I'm using copyhere method to copy files and I want to overwrite existing files:
The only problem is that there is a bug in the overwrite functionality in the copyhere method. Does anyone know another simple way to overwrite files that I am copying, or a simple way to check those files and delete them before hand? It is not as simple as hard coding the file paths so I'm not sure exactly what to do. Here is my whole function:
I'm using copyhere method to copy files and I want to overwrite existing files:
Code:
objFolder_DESTINATION.copyhere objFiles_SOURCE, 16
The only problem is that there is a bug in the overwrite functionality in the copyhere method. Does anyone know another simple way to overwrite files that I am copying, or a simple way to check those files and delete them before hand? It is not as simple as hard coding the file paths so I'm not sure exactly what to do. Here is my whole function:
Code:
Function UnzipFile(varFileName_SOURCE_COMPLETE As Variant, varFolderName_DESTINATION_COMPLETE As Variant) As String
On Error GoTo Function_Execution_Failure
Dim objFSO As New FileSystemObject
Dim objShellApplication As Variant
Dim objFiles_SOURCE As Variant
Dim objFolder_DESTINATION As Variant
If objFSO.FileExists(varFileName_SOURCE_COMPLETE) = False Then
UnzipFile = "Error: file " & CStr(varFileName_SOURCE_COMPLETE) & " does not exist, aborting operation."
GoTo Function_Execution_Failure
End If
If objFSO.FolderExists(CStr(varFolderName_DESTINATION_COMPLETE)) = False Then
objFSO.CreateFolder (CStr(varFolderName_DESTINATION_COMPLETE))
End If
Set objShellApplication = CreateObject("Shell.Application")
Set objFiles_SOURCE = objShellApplication.Namespace(varFileName_SOURCE_COMPLETE).Items()
Set objFolder_DESTINATION = objShellApplication.Namespace(varFolderName_DESTINATION_COMPLETE)
objFolder_DESTINATION.copyhere objFiles_SOURCE, 16
Wait
Function_Execution_Success:
GoTo Quit_function
Function_Execution_Failure:
UnzipFile = "Error: " & Err.Description
Call reportError("UnzipFile", Err.Number, Err.Description)
Quit_function:
Set objFSO = Nothing
Set objShellApplication = Nothing
Set objFiles_SOURCE = Nothing
Set objFolder_DESTINATION = Nothing
End Function