View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 292
Default GetSaveAsFilename - Save as box

Hi

What do you want to happen if the file exists ?

Best wishes Harald

"Der " skrev i melding
...
Hi
I have a following problem. I have a document with macro from which I
open and convert other csv files. At the end of conversion I want to
get Save as box. To do this I wrote the following code:

NameAk = Sheets(1).Name & ".xls"
NewName =
Application.GetSaveAsFilename(InitialFileName:=Act iveWorkbook.Path &
"\" & _
NameAk, FileFilter:="Excel Workbooks (*.xls), *.xls")

If NewName < False Then
ActiveWorkbook.SaveAs Filename:=NewName,
FileFormat:=xlWorkbookNormal
End If

Everything is all right if I push "save" or "cancel" button. Problem
occurs when I push "save" and there is another file with the same name
in this directory. The second box occures and I got the message:"Do you
want to replace the file?" If I answer yes then it is ok but if I answer
cancel or no then the macro crashes and the the message I get is:
"method SaveAs or object _Woorkbook failed". Can you advise me how I
should modify my code?


---
Message posted from http://www.ExcelForum.com/