Ghassen Ben Lazhar
Ghassen Ben Lazhar

Reputation: 19

Forget to save excel macro

I was working on an excel macro and apparently I did not saved with a format that support vba macros. So when I open the file I cannot found the vba code. Is there a way to restore the code I wrote, especially that I pushed the save button in the editor several times during the core writing ?

I would be grateful if you can save my 4 hours work.

Upvotes: 1

Views: 18010

Answers (2)

Vityata
Vityata

Reputation: 43595

Short answer: No

Long answer: If you can run fast, by breaking the speed of light, you would be able to turn back time, thus you would be able to go in the past and save your file correctly.

Answer bringing some value:

  • No, but make sure that you enable autosave next time.
  • Make a habit of saving manually every 10 minutes.
  • Start using version control system, where you commit every time you have something new - Best way to do Version Control for MS Excel

Upvotes: 3

Mathieu Guindon
Mathieu Guindon

Reputation: 71247

You lost your work.

The good news? Every time I had to re-write a piece of code, the 2nd time around was consistently much better than the first. So, take that lost work as an opportunity!


Unless... it's possible you have Excel's autosave feature turned on:

Excel Options / Save

Look under %appdata%\Microsoft\Excel; with a little luck you'll find a copy of your work saved as a .xlsb file, and all you'll have lost is 10 minutes of work. If you're lucky.

That said...

I pushed the save button in the editor several times during the core writing

The VBE doesn't do the saving. If you bring up the VBE in a brand new unsaved workbook and hit the VBE's [Save] button, what happens is that the VBE invokes the host application's save mechanism, and thus Excel prompts you for a file name.

If you really hit the [Save] button several times in the editor, either you did save your work, or you explicitly cancelled the "Save As" dialog that popped up every time - in which case your work is indeed lost.

If you did hit that [Save] button and Excel didn't prompt you for a file name, then you did save it. Try looking for it in Excel's recent documents.

And hit Ctrl+S more than once every 4 hours!

Upvotes: 9

Related Questions