VBA Save As problem with file that already exist

D

DVAL

Hi!

I have the following macro:

Sub save()
FN = Sheet1.Range("H30").Text
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & FN
ActiveWorkbook.close
End Sub


that works correct except if I already have the file with the same name.
In that case I got Excel message:
A file named " ......... " already exists in this location.
If I click 'No' or 'Cancel' the SaveAs gives me an error:
Run-time error '1004'

I don't want to use the Application.DisplayAlerts = False,
because I want the user to be aware that there is a file already named the
same.

I want on case 'No' to bring up the save as dialog box
and on Case Cancel to exit from macro

Thank you for reading this especially if you are able to help me out on
this.
 
D

Dave Peterson

Check your other post.

Hi!

I have the following macro:

Sub save()
FN = Sheet1.Range("H30").Text
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & FN
ActiveWorkbook.close
End Sub


that works correct except if I already have the file with the same name.
In that case I got Excel message:
A file named " ......... " already exists in this location.
If I click 'No' or 'Cancel' the SaveAs gives me an error:
Run-time error '1004'

I don't want to use the Application.DisplayAlerts = False,
because I want the user to be aware that there is a file already named the same.

I want on case 'No' to bring up the save as dialog box
and on Case Cancel to exit from macro

Thank you for reading this especially if you are able to help me out on this.
 
S

Snoopy

Hi!

I have the following macro:

Sub save()
    FN = Sheet1.Range("H30").Text
    ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & FN
    ActiveWorkbook.close
End Sub

that works correct except if I already have thefilewith the same name.
In that case I got Excel message:
Afilenamed " ......... " already exists in this location.
If I click 'No' or 'Cancel' the SaveAs gives me an error:
Run-time error '1004'

I don't want to use the Application.DisplayAlerts = False,
because I want the user to be aware that there is afilealready named the
same.

I want on case 'No' to bring up the save as dialog box
and on Case Cancel to exit from macro

Thank you for reading this especially if you are able to help me out on
this.

I have the same "problem" - did you get a clue?
Best Regards Snoopy
 

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

Top