Export to CSV - Excel

Associate
Joined
7 Aug 2008
Posts
302
Hi,

I've currently got a Spreadsheet which uses a Macro to Export to CSV. I have been really lazy and done the code just by recording the macro.

I was just wondering what sort of code I need to allow it to automatically point to a specific directory when the Save As dialog pops up.

Cheers,
Tom
 
Associate
OP
Joined
7 Aug 2008
Posts
302
At the moment I have just got a bog standard:

Code:
Sub ExportToCSV()

Dim strFileName As String

strFileName = Application.GetSaveAsFilename(filefilter:="Comma Seperated Values (*.csv), *.csv")

If strFileName <> "False" Then
    ActiveWorkbook.SaveAs strFileName, xlCSV
End If

End Sub
 
Associate
OP
Joined
7 Aug 2008
Posts
302
Hi,

Cheers for the reply, that works well! How would I go about giving the file a Default name when the Save As dialogue pops up?

Also, I have some fields I have defined names to which I then move to a separate sheet so I can export to a CSV. So for example C1 is named Test. However, when the row is deleted with that named cell on it, it won't automatically rename C1 to Test. How can I go about setting this so C1 is Test regardless of if the rows are deleted?
 
Back
Top Bottom