Macros Containing a File Save As & Tab Deletions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro that saves off a copy of the file, replacing the existing
saved off copy. Even though I record "yes" to replace the existing copy I am
always prompted to say/click "yes" again when the macro runs. Also, on
another macro, I delete a few tabs from the copy. I am prompted during the
recording (like "are you sure you want to delete this tab") and I still get
prompted again when the macro runs.

Is there a way to program it so the macro saves over an existing or delete
tabs without user intervention, to agree with what has already been agreed
to, while the macro is actually running?

Many thanks in advance!

Regards,
Mike
 
If you use something like:

Activeworkbook.save
or
thisworkbook.save

You shouldn't be prompted to overwrite the existing file.

If you're using .saveas, you can avoid the prompt:

application.displayalerts = false
activeworkbook.saveas .....
application.displayalerts = true

And the same .displayalerts will stop the prompt when you delete a sheet in
code.
 
Mike

Wrap the actions inside these two lines.

Application.DisplayAlerts = False

'do your code stuff

Application.DisplayAlerts = True


Gord Dibben MS Excel MVP
 
Dave - worked great/excellent! Thank you!

Dave Peterson said:
If you use something like:

Activeworkbook.save
or
thisworkbook.save

You shouldn't be prompted to overwrite the existing file.

If you're using .saveas, you can avoid the prompt:

application.displayalerts = false
activeworkbook.saveas .....
application.displayalerts = true

And the same .displayalerts will stop the prompt when you delete a sheet in
code.
 
Gord - thank you - it worked great.

Gord Dibben said:
Mike

Wrap the actions inside these two lines.

Application.DisplayAlerts = False

'do your code stuff

Application.DisplayAlerts = True


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

macro to delete another macro 1
Macro prompt 2
Save As / Overwrite 4
Personal Macro 1
Excel 2007: Saving a file with a Macro 1
Pasting cell contents into a macro 1
Macro problem 4
File Size 3

Back
Top