Link to home
Start Free TrialLog in
Avatar of Norma Posy
Norma PosyFlag for United States of America

asked on

Declining a "Save As" produces an error

My application generates  a number of Excel spreadsheets.
My code automates naming the spreadsheet, and saving it. Code line:

.Application.Workbooks(sCurrentName).SaveAs (sSavePath & sWorkbookName)

It may happen that the destination folder already contains an older file with the same name.
If this happens, the user is asked if the old file should be replaced with this one.
If "No" is selected, the VB6 code receives an error.

I've worked around this by setting a flag just prior to the above line of code, then in the ErrorHandler, jumping over the error message box.

That works, but it is a cobble. It means that I really am cheating, because I don't know why the error is triggered.

Is there a cleaner way to handle this?
Or should I use my cobble?
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Norma Posy

ASKER

Thank You.