VBA to Turn OFF 'AutoSave'

rjbinney

Active Member
Joined
Dec 20, 2010
Messages
279
Office Version
  1. 365
Platform
  1. Windows
I have a pretty hefty file with a macro that does a couple of "Save As" (for backup, mobile-friendly, etc.).

The final step of the macro is to open up the original file, which is stored in OneDrive.

In the last few weeks, when it opens the original file, it flips the AutoSave option to ON.

In other words, I have AutoSave OFF. When I run the macro, Bill Gates decides I want it back ON. I don't.

What can I add to the end of my code to keep it OFF? Thanks!

BTW, here's the last few lines of the macro:
Code:
'Turn Alerts Back On
 Application.DisplayAlerts = True
 
 'Close the Copies and Reopen the Master
   Dim ans As String
    ans = "Inventory_for_Dropbox.xlsx"
    Workbooks.Open Filename:="C:\Users\Me\OneDrive\1D Documents\Databases\Inventory Master.xlsm"
    Workbooks(ans).Close
      
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Will give that a shot, thanks.

For whatever reason, I thought AutoRecover was different from the snazzy, new (and very much despised) "AutoSave" tickswitch integrated in Office docs saved on OneDrive (don't get me started).

 
Upvote 0
I have a similar problem with my olerd macros that use the SaveAs command. Once the new Excel365 AutoSave is on, the SaveAs command is inoperative. Then my old macro fails. I can turn off AutoSave manually before running my old macro which will then work fine as SaveAs is operative in an AutoSave OFF environment. What I wanted to do was add a VBA line to turn off AutoSave before executing the SaveAs line. The suggestion above of turning off AutoRecover does not seem to turn off AutoSave. I need another idea. Not being a VBA expert i need help! Thanks
 
Upvote 0
I don't know if my experience will help you.

I have AutoSave turned OFF for this file, all the time. (Mainly because I mess with these macros, and even though I keep a "live" backup, it's just easier to go old school on this.)

So, I use:
Code:
 'Turn Save As Alerts Off
Application.DisplayAlerts = False
...so I can "Save As" over existing documents and not get the "Are you sure?" dialog.
(At the end of my macro I have to turn it off!:
Code:
'Turn Alerts Back On
 Application.DisplayAlerts = True

I save a copy of the file I'm using:
Code:
'Save Current
    ActiveWorkbook.Save

And then I save the backup - different directory, different name (so, essentially, a "Save As")
Code:
'Save Local Backup
    ChDir "C:\Users\Personal\Documents"
    ActiveWorkbook.SaveAs Filename:="Inventory Backup.xlsm", FileFormat:=52

Of course, YMMV.
 
Upvote 0
Just use this in WorkbookOpen event:

Code:
    If Val(Application.Version) > 15 Then
        If ActiveWorkbook.AutoSaveOn Then ActiveWorkbook.AutoSaveOn = False
    End If
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,558
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top