title: Saving excel file at two different locations
body: <p>I have to do this whenever I save the excel file:</p>
  
  <ol>
  <li><p>Save the file at one drive location (overwrite if same name file exists)</p></li>
  <li><p>Go back to original location of the file and save it there as well (overwrite the file)</p></li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
      Application.ScreenUpdating = False
      Application.EnableEvents = False
      Application.DisplayAlerts = False
  
      Dim thisPath As String
      Dim oneDrivePath As String
  
      thisPath = ThisWorkbook.Path &amp; "\" &amp; ThisWorkbook.Name
      oneDrivePath = "C:\Users\Folder\OneDrive\" &amp; ThisWorkbook.Name
  
      ActiveWorkbook.SaveAs _
      Filename:=oneDrivePath
  
      Do
      Loop Until ThisWorkbook.Saved
  
      ActiveWorkbook.SaveAs _
      Filename:=thisPath
  
      Do
      Loop Until ThisWorkbook.Saved
  
      Application.DisplayAlerts = True
      Application.EnableEvents = True
      Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>But this doesn't works it's stucks in an infinte loop or Excel goes in Not Responding State. Anyidea how to achieve this task ?</p>
  
  <p>The reason I can think of why it fails is maybe it's triggered everytime the file is saved but shouldn't <code>Application.EnableEvents = False</code> stop it from happening ? '</p>
  
  <blockquote>
    <p>EDIT#1:</p>
  </blockquote>
  
  <p>I tried stepping through the code it goes into <code>Not Responding State</code> after the Code gets though <code>End Sub</code> line</p>