View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default How check for No/Cancel Button when SaveAs and file already exists?

Joe,

What are you tryin g to do, not save it if it already exists? If so, try
trapping it, and don't save if so

Function FileExists(sFilename As String) As Boolean
FileExists = Dir(sFilename) < ""
End Function



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Joe HM" wrote in message
oups.com...
Hello -

I have a quick question: I use the ThisWorkbook.SaveAs function to
save a file but if the file already exists, Excel shows a warning. The
problem is that if I say either No or Cancel, there is an exception
thrown. How can I catch the result of that MsgBox()?

Thanks!
Joe