-
Xls export to txt
Hi.
Dear I have the following routine that exports to txt
Code:
Sub Exportar()
Application.DisplayAlerts = False
template_file = ActiveWorkbook.FullName
fileSaveName = Application.GetSaveAsFilename( _
InitialFileName:="C:\username" + _
VBA.Strings.Format(Now, "mmddyyyy") + ".txt", _
fileFilter:="Text Files (*.txt), *.txt")
If fileSaveName = False Then
Exit Sub
End If
'cria uma cópia da pasta de trabalho atual da planilha atual
Dim newBook As Workbook
Dim plan As Worksheet
Set newBook = Workbooks.Add
ThisWorkbook.ActiveSheet.Copy Before:=newBook.Sheets(1)
'exclui as demais planilhas
For Each plan In newBook.Sheets
If plan.Name <> ActiveSheet.Name Then
newBook.Worksheets(plan.Index).Delete
End If
Next
newBook.SaveAs Filename:= _
fileSaveName, FileFormat:=xlTextWindows, _
CreateBackup:=False
'fecha a pasta de trabalho gerada
newBook.Close SaveChanges:=True
Set newBook = Nothing
MsgBox "O arquivo foi exportado com sucesso! ", vbInformation, "Exportar arquivos"
End Sub
The doubt is as follows, in order that the code is the same txt all exports to spreadsheet rows or 65536 rows! How can I adjust to the routine that exports only rows filled?
Cross-Post
Xls export to txt
I appreciate the help
-
-
I did not understand ....
I need a code to get a file in xls, and transfome in a txt file
-
Hi
That's what the code does.
Paste the code in a standard module and pass the parameters.
Code:
Sub ConvertRangeIntoTextFile(ByRef RangeToConvert, ByVal FileName As String, _
Optional FilePath As String, Optional Delim As String = vbTab)
where pass the range,filename and optional filepath as well as the delimiter. That's all.
-
hI.
in my testing is being created a file in XLS format