View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
yshridhar yshridhar is offline
external usenet poster
 
Posts: 229
Default save as macro for same file name

Hello everybody
I wrote a macro that save the workbook as with the given name. I am
encoutering a problem, if the file is already exists it is asking to
overwrite. in this case what i want is to warn the user as the file already
exists and prompt to enter new name to save as.

The following is the code

Sub itr12()

Dim fpath As String
Dim fname As String

fpath = ActiveWorkbook.Path
fname = Sheets("data").Range("b3")

On Error Resume Next
MkDir fpath & "\" & Format(Now, "dd-mmm")
ActiveWorkbook.SaveAs (ActiveWorkbook.Path & "\" & Format(Now, "dd-mmm")
& "\" & fname & ".XLS")

End Sub
The file containing macro is stored in the "fpath" directory.
i am using off-203
any suggestions
thanks in advance
With best regards
sreedhar