How to overwrite my current active open workbook

fluffyvampirekitten

Board Regular
Joined
Jul 1, 2015
Messages
72
I wanna overwrite my active workbook
Any ideas?
Code:
Application.EnableEvents = False
        filename = Application.GetSaveAsFilename
        ThisWorkbook.SaveAs filename & ".xls"
        ThisWorkbook.Saved = True
        Application.EnableEvents = True

I have this few lines of codes.However , it created another file name instead of overwriting it
How to put all the format -
Im using excel 2013 .
Code:
ThisWorkbook.SaveAs filename & ".xls"

Thanks in advance
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I wanna overwrite my active workbook
Any ideas?
Code:
Application.EnableEvents = False
        filename = Application.GetSaveAsFilename
        ThisWorkbook.SaveAs filename & ".xls"
        ThisWorkbook.Saved = True
        Application.EnableEvents = True

I have this few lines of codes.However , it created another file name instead of overwriting it
How to put all the format -
Im using excel 2013 .
Code:
ThisWorkbook.SaveAs filename & ".xls"

Thanks in advance
Code:
ThisWorkbook.Save
 
Upvote 0
It isn't working , it wasnt even saving . any other options ?
It doesn't overwriting
If that did not save your workbook with the current changes, you either have a big problem or I am totally misunderstanding what you mean by overwrite. The syntax for saving a workbook with changes is
Code:
[I]Workbook.Save
[/I]
The Workbook can be a variable that represents a workbook object. It will save the current file with any changes and overwrite the stored file.
 
Last edited:
Upvote 0
If you want to only change the name of the file, without making any changes to the data, formulas or format in the workbook, then use this syntax:
Code:
MyOldFile.xlsx As MyNewFile.xlsx
You cannot do this with the workbook open and active. It has to be done from a different workbook than the one being changed.
 
Upvote 0

Forum statistics

Threads
1,221,525
Messages
6,160,329
Members
451,637
Latest member
hvp2262

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