Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
From VB script, when executing the code:
ActiveWorkbook.SaveAs FileName:="C:\ZZ.XLS" a dialogue comes up when the file exists already, requesting whether the filename should be overwritten. How can I retrieve the option exercised by the user: YES, NO, CANCEL? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What you should do is determine whether the file exists before the SaveAs
and ask the user what he wants to do: Sub a() Dim Resp As Integer Dim FName As String FName = "c:\abc.xls" If Dir(FName) < "" Then Resp = MsgBox(FName & " exists. Replace it?", vbYesNoCancel) Select Case Resp Case vbYes: MsgBox "User chose replace" Case vbNo: MsgBox "User chose not to replace" Case vbCancel: MsgBox "User chose cancel" End Select End If End Sub Of course in place of the message boxes in the Select you'd put the appropriate actions, for Yes doing a SaveAs with Application.DisplayAlerts set to False so the user is not prompted to replace the existing file. -- Jim "AA2e72E" wrote in message ... | From VB script, when executing the code: | | ActiveWorkbook.SaveAs FileName:="C:\ZZ.XLS" | | a dialogue comes up when the file exists already, requesting whether the | filename should be overwritten. How can I retrieve the option exercised by | the user: YES, NO, CANCEL? | | |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find and Replace - Replace with Blank Space | Excel Discussion (Misc queries) | |||
Can I replace a ' at the beginning of a text cell using Replace | Excel Discussion (Misc queries) | |||
Replace dialog should put focus on "Find What" not "Replace With" | Excel Discussion (Misc queries) | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions | |||
How can I use replace(alt+H) for mutiple items needing replace | Excel Worksheet Functions |