Test for file existence

  • Thread starter Thread starter Joseph
  • Start date Start date
J

Joseph

Hi Tom,

I just got a method 'saveas' of object 'workbook' failed. Any Ideas?

Cheer
 
I changed P to C and created you structure. This revision worked fine for
me. (I changed C back to P).


Sub AAAA()

sName = "P:\clevedon staff\activities\" & _
Application.UserName & "\" & Application.UserName _
& " " & Format(Now, "DDMMYY") & " ActivityLog.csv"

If Dir(sName) <> "" Then
Kill sName
End If
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
sName, FileFormat:=xlCSV, _
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Saved = True
Application.Quit
Application.DisplayAlerts = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top