VBA Autosave upon starting Excel

Mette85

New Member
Joined
Mar 29, 2022
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello.

is it possible autorun this VBA code when i open a excel file?

Sub SaveThis()
Application.DisplayAlerts = False
ThisWorkbook.Save

Application.OnTime Now + TimeValue("00:30:00"), "SaveThis"
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
If you mean "when you open that file and the macro is in that file", then just add this to the ThisWorkbook vbe module:
VBA Code:
Private Sub Workbook_Open()
    SaveThis
End Sub
but if you mean "when you open every file (whatever Excel file) that dosen't contain that macro", well not so simple, you could try to save a file (with both macros) in the XLStart folder. Then you would use ActiveWorkbook instead of ThisWorkbook, anyway it would still miss the first Save.
 
Last edited:
Upvote 0
i tryed it like this. the reason i want it to run the atuosave macro when they open the file is because i am using that macro on a Storage system that is running tablets.. so its hard to push the save button in excel since it`s so small :P and the tutchpen isnt that great.

so i am trying to remove the hassle with saving the dokument all the time :P
 

Attachments

  • excel help.png
    excel help.png
    60.7 KB · Views: 7
Upvote 0
i tryed it like this. the reason i want it to run the atuosave macro when they open the file is because i am using that macro on a Storage system that is running tablets.. so its hard to push the save button in excel since it`s so small :P and the tutchpen isnt that great.

so i am trying to remove the hassle with saving the dokument all the time :P
but it still does not autostart the autosave vba
 
Upvote 0
You did it the other way around, I had said that the macro Workbook_Open macro went into the ThisWorkbook module.
 
Upvote 0
Solution
You did it the other way around, I had said that the macro Workbook_Open macro went into the ThisWorkbook module.



so sorry about that... my fault.. was tired yesterday, and today :P but thank you soo much for that! anything i can help you with? :D
 
Upvote 0
Thanks for the positive feedback(y), glad having been of some help.
Oh yeah, you can help make me win at the lottery ?.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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