Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggling AutoSave On/Off through VBA in Excel

Status
Not open for further replies.

Goska

Programmer
Jun 21, 2001
74
0
0
US
I want to turn AutoSave in Excel on/off automatically with VBA. I have a few sensitive areas in a program I am writing, where the file cannot be resaved under a name other than the one I have specified. I am aware that I could change my code to work around this, but it would not be worth the time to do it if I can turn AutoSave off.

 
Is this the autosave addin? Store300

Store300@ftnetwork.com
 
Yes, it is, and I found the code elsewhere over the weekend. I meant to post it here if anyone else was ever doing the keyword search, so here goes.

call autosave(true)

Sub AutoSave(Setting As Boolean)
Workbooks("autosave.xla").Excel4IntlMacroSheets("Loc Table") _
.Range("ud01n.Do_Save").Value = Setting
Run "autosave.xla!mcs05.ClearOnTime"
Run "autosave.xla!mcs03.SetOnTime"
Run "autosave.xla!mcs01.CheckCommand"
End Sub

Thanks for offering the help.

 
Where would you put this in the worksheet? Im still new to VBA and was wondering thanks.
 
I set this up as a subroutine since I use it often. I put the subroutine in a Module that I renamed as FileFunctions. This allows me to use it anywhere I want with a single line of code.

Sub AutoSave(Setting As Boolean)
Workbooks("autosave.xla").Excel4IntlMacroSheets("Loc Table") _
.Range("ud01n.Do_Save").Value = Setting
Run "autosave.xla!mcs05.ClearOnTime"
Run "autosave.xla!mcs03.SetOnTime"
Run "autosave.xla!mcs01.CheckCommand"
End Sub

The above goes in FileFunctions as it is above. This is the exact cut-and-paste syntax that you can take with you. I don't reccomend changing anything. To use this function, go find the space in the code where you want to toggle AutoSave and enter the line

Call FileFunctions.AutoSave(true)

to turn it on. Replace true with false to turn it off.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top