I am trying to export a particular column from a excel sheet into .txt file format. I would like to allow the user to provide name and location of the file to be saved.
I was able to save it in .xlsx format. Anyone know how to export it into .dat format ?
This is my code for .xlsx export,
Workbooks.Add
ActiveSheet.Paste
Cells.Select
Selection.Columns.AutoFit
Application.CutCopyMode = False
sFileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitialName, fileFilter:="Excel Files (*.xlsx), *.xls")
If sFileSaveName <> False Then
ActiveWorkbook.SaveCopyAs sFileSaveName
MsgBox "File Successfully Saved!"
ActiveWorkbook.Close
End if
I have tried something like this,
myFile = Application.GetSaveAsFilename(filefilter:="Text Files (*.txt),*txt")
But my output got messed up completely and looks like this -
Thanks.