View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
AB[_2_] AB[_2_] is offline
external usenet poster
 
Posts: 236
Default if workbooks exists delete

Function IsFileThere() As Boolean
Dim fso As Object

Set fso = CreateObject("Scripting.Filesystemobject")
If fso.FileExists("C:\CertainFileName.xls") Then' Your file name
goes there with full path
IsFileThere = True
Else
IsFileThere = False
End If

End Function


On 4 Dec, 14:40, Stephen wrote:
Hi Folks,

I have a simple little problem where before my macro create a temp file by a
certain name, I want it to check if that file already exists and if it does,
delete it.

I have code that will delete the temp file as one of the finishing touches
on the procedure, but occasionally the program won't run all the way through
and upon autorecovery it needs user input asking if you want to overright the
existing file. *I'd rather simply check for it and remove it if exists before
getting to that point.

TIA!