Hi all,

Here is the code I have to copy the file:
VB Code:
  1. Option Explicit
  2.  
  3. Private Type SHFILEOPSTRUCT
  4.     hwnd As Long
  5.     wFunc As Long
  6.     pFrom As String
  7.     pTo As String
  8.     fFlags As Integer
  9.     fAnyOperationsAborted As Long
  10.     hNameMappings As Long
  11.     lpszProgressTitle As String
  12. End Type
  13.  
  14. Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
  15.  
  16. Private Const FOF_ALLOWUNDO = &H40
  17. Private Const FOF_NOCONFIRMATION = &H10
  18. Private Const FO_COPY = &H2
  19.  
  20. Public Function ShellFileCopy(src As String, dest As String, Optional NoConfirm As Boolean = False) As Boolean
  21. 'PURPOSE: COPY FILES VIA SHELL API
  22. 'THIS DISPLAYS THE COPY PROGRESS DIALOG BOX
  23. 'PARAMETERS: src: Source File (FullPath)
  24. 'dest: Destination File (FullPath)
  25. 'NoConfirm (Optional): If set to true, no confirmation box is displayed when overwriting
  26. 'existing files, and no copy progress dialog box is displayed.
  27.  
  28. 'Returns (True if Successful, false otherwise)
  29.  
  30. 'EXAMPLE:
  31. 'dim bSuccess as boolean
  32. 'bSuccess = ShellFileCopy ("C:\MyFile.txt", "D:\MyFile.txt")
  33. 'bSuccess = ShellFileCopy ("C:\MyFile.txt", "D:\MyFile.txt", False)
  34.  
  35.     Dim WinType_SFO As SHFILEOPSTRUCT
  36.     Dim lRet As Long
  37.     Dim lflags As Long
  38.  
  39.     lflags = FOF_ALLOWUNDO
  40.     If NoConfirm Then lflags = lflags & FOF_NOCONFIRMATION
  41.     With WinType_SFO
  42.         .wFunc = FO_COPY
  43.         .pFrom = src
  44.         .pTo = dest
  45.         .fFlags = lflags
  46.     End With
  47.  
  48.     lRet = SHFileOperation(WinType_SFO)
  49.     ShellFileCopy = (lRet = 0)
  50. End Function
  51.  
  52. Private Sub Form_Load()
  53. Dim bsuccess As Boolean
  54. bsuccess = ShellFileCopy("C:\Temp\Excel[1].zip", "C:\Temp\Excel[2].zip", False)
  55. End Sub

What I want to do is to modify this function to copy the file with animated progress and overwrite the existing file by default.

Thanks,

Kanna.