title: Unable to save an unshared version of Excel workbook using VBA
body: <p>I am trying to save a version of a shared excel file every time the file is saved. I want the file to be unshared and have no VBA macros. The code I am currently using is as follows:</p>
  
  <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
  
  Dim x As String, y As String, z As String
  x = "Enable Autosave"
  y = Now()
  z = "C:\Users\.....\MTMtest-" &amp; Format(y, "mm-dd-yy hhmm") &amp; ".xls"
  
  If Sheet3.Cells(1, 5).Value = x Or Sheet4.Cells(1, 5).Value = x Or Sheet5.Cells(1, 5).Value = x Or Sheet6.Cells(1, 5).Value = x Then
  
          ActiveWorkbook.SaveCopyAs (z)
  
      If ActiveWorkbook.MultiUserEditing Then
          Application.Workbooks.Open (z)
          Workbooks("MTMtest-" &amp; Format(y, "mm-dd-yy hhmm") &amp; ".xls").Activate
          ActiveWorkbook.ExclusiveAccess
          ActiveWorkbook.Save
          ActiveWorkbook.Close
      End If
  
  End If
  
  End Sub
  </code></pre>
  
  <p>When I save the shared file, I get a popup asking if I would like to remove the workbook from shared use. When I click yes, I'm given an error: Run-time error '1004' Microsoft Excel cannot access the file. Clicking End gets me an unshared copy, but it is still open.</p>
  
  <p>After I close the copy and attempt to close the original I get the error: The file is locked. This forces me to close the original with task manager.</p>
  
  <p>My question is: How do i get this program to just save a non-macro, non shared copy of my current workbook?</p>