title: VBA Copying File; surpress "file already exists" and determine if successful?
body: <p>I have some code that I am using to copy a folder from my local PC to a network shared drive (to backup).  I have two questions around my code.  First, when the code runs, it acts just like a copy/paste in Windows in that if the files already exist, it asks me if I want to overwrite them.  I do want to overwrite them, as I am running the code every day, so how do I suppress this?</p>
  
  <p>Second, I would like to be able to determine if the copy/paste happened successfully.  Is there a way to do this?</p>
  
  <p>I was using the VBA copy functionality, but it showed no progress bar, so I was afraid I would open Outlook at some point and mess up the file copy.
  Anyways, here is my code.</p>
  
  <pre><code>Private Sub Main()
  
      'unrelated code
  
      If Len(Dir("\\aubinsFS01\E9786046$\")) &lt;&gt; 0 Then
          If Len(Dir("C:\Users\E9786046\Documents\Outlook Files\")) &lt;&gt; 0 Then
  
                  'Taken from multiple examples
                  'http://www.mrexcel.com/forum/excel-questions/238407-progress-bar-copying-file.html
  
                  Dim FromPath As Variant
                  Dim ToPath As Variant
  
                  FromPath = "C:\Users\E9786046\Documents\Outlook Files\"  '&lt;&lt; Change
                  ToPath = "\\aubinsFS01\E9786046$\Personal Folder Backup"    '&lt;&lt; Change
  
                  Application.Wait (Now + TimeValue("0:00:05"))       'Delay to allow Outlook to close
  
                  Set objShell = CreateObject("Shell.Application")
                  '//The source Folder to CopyFrom:
                  Set objFolder = objShell.Namespace(FromPath)
  
                  '//The source Folder to CopyTo:
                  objFolder.CopyHere ToPath, &amp;H0&amp;
  
                  Set objShell = Nothing
                  Set objFolder = Nothing
  
                  MsgBox "You can find the files and subfolders from " &amp; FromPath &amp; " in " &amp; ToPath
          Else
              MsgBox "Personal folder location not found.  Please check your personal folder."
          End If
      Else
          MsgBox "Network location not available.  Check your shared drives for connection."
      End If
  
      ThisWorkbook.Close
      End
  
  End Sub
  </code></pre>