I try to make a macro for saving an Excel sheet to a .CSV file with "@" as delimiter.
At the line "Open fname For Output As #fnum", the Error 53, "no file found" occurs.
The Excel-help is saying that if the file is not present, a new file will be made.
This error occurs now and then, How to proceed?
Full macro:
At the line "Open fname For Output As #fnum", the Error 53, "no file found" occurs.
The Excel-help is saying that if the file is not present, a new file will be made.
This error occurs now and then, How to proceed?
Full macro:
Code:
Sub SaveAsCSV()
Path = "O:\actueel\"
Fname1 = Path & Range("E2").Value & ".csv"
fname = Application.GetSaveAsFilename(Fname1, "CSV bestand (*.csv), *.csv", , "")
If fname = False Then
MsgBox "Macro Geannuleerd"
Exit Sub
End If
sep = "@"
fnum = FreeFile
Close #fnum
Open fname For Output As #fnum
lastrow = Range("K65536").End(xlUp).Row
For Row = 2 To lastrow
A = Cells(Row, 4).Value
B = Cells(Row, 1).Value
Print #fnum, A & sep & B & sep
Next Row
Close #fnum
End Sub
Last edited by a moderator: