nigelandrewfoster
Well-known Member
- Joined
- May 27, 2009
- Messages
- 747
The following code stops at the red line with "Method 'SaveAs' of object '_Workbook' failed. Does anyone know why?
FF="xlCSV". It works fine if I replace
with
. Thanks.
FF="xlCSV". It works fine if I replace
Code:
FileFormat:=FF
Code:
FileFormat:=xlCSV
Code:
Sub SaveIt(FileNm, FF)
Dim FSO As Object, a
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(FileNm) Then FSO.DeleteFile FileNm
If FSO.FileExists(FileNm) Then
a = MsgBox(FileNm & " already exists, and cannot be deleted." & vbCr & vbCr & "Contact support on 0xxxxxxxxxx1", _
vbCritical, "ERROR - FILE EXISTS")
Exit Sub
End If
[COLOR="Red"] ActiveWorkbook.SaveAs Filename:=FileNm, FileFormat:=FF[/COLOR]
End Sub