Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Vergel! Definitely looks like it will work; will give it a go....have
a great evening, and thanks again for your help. "Vergel Adriano" wrote: You can check for file existence before calling the SaveAs. Something like this: Do fname = Application.GetSaveAsFilename(InitialFileName:="", FileFilter:="Microsoft Excel Workbook (*.xls), *.xls") If fname < False Then 'check if file exists If Dir(fname) < "" Then 'File exists. Ask if okay to replace If vbYes < MsgBox("File already exists. Do you want to replace it?", vbYesNo) Then 'not ok to replace, set fname to False fname = False End If End If End If Loop Until fname < False ActiveWorkbook.SaveAs Filename:=fname, FileFormat:=xlWorkbookNormal -- Hope that helps. Vergel Adriano "Paige" wrote: When I bring up the saveas menu, if someone selects an existing file and hits Save, they then get the warning message saying the file already exists and do they want to replace it. If they hit 'No' or 'Cancel', then the code errors out. How do I fix this? I still want them to get the warning message, but if they select 'No' or 'Cancel', the message should disappear and take them back to the saveas menu so they can select another file or enter a new file name. The current code I'm using is: Do FName = Application.GetSaveAsFilename(InitialFileName:="", FileFilter:="Microsoft Excel Workbook (*.xls), *.xls") Loop Until FName < False ActiveWorkbook.SaveAs Filename:=FName, FileFormat:=xlWorkbookNormal Appreciate any help I can get on this; thanks.... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code Bombs in Excel 2007 | Excel Programming | |||
Excel bombs out in macro...help please!! | Excel Programming | |||
Code bombs at line indicated, why? | Excel Programming | |||
sumproduct bombs out | Excel Worksheet Functions | |||
Macro runs in Excel 2003, bombs in XP - Compatability question | Excel Programming |