Xls export to txt

marreco

Well-known Member
Joined
Jan 1, 2011
Messages
609
Office Version
  1. 2010
Platform
  1. Windows
Hi
Dear I have the following routine that exports to txt
Code:
[COLOR=#000000][FONT=Verdana]Sub Exportar() [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    Application.DisplayAlerts = False [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    template_file = ActiveWorkbook.FullName [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    fileSaveName = Application.GetSaveAsFilename( _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]                   InitialFileName:="C:\username" + _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]                                    VBA.Strings.Format(Now, "mmddyyyy") + ".txt", _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]                   fileFilter:="Text Files (*.txt), *.txt") [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    If fileSaveName = False Then [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]        Exit Sub [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    End If [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    'cria uma cópia da pasta de trabalho atual da planilha atual [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    Dim newBook As Workbook [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    Dim plan As Worksheet [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    Set newBook = Workbooks.Add [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    ThisWorkbook.ActiveSheet.Copy Before:=newBook.Sheets(1) [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    'exclui as demais planilhas [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    For Each plan In newBook.Sheets [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]        If plan.Name <> ActiveSheet.Name Then [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]            newBook.Worksheets(plan.Index).Delete [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]        End If [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    Next [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    newBook.SaveAs Filename:= _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]                          fileSaveName, FileFormat:=xlTextWindows, _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]                          CreateBackup:=False [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    'fecha a pasta de trabalho gerada [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    newBook.Close SaveChanges:=True [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]    Set newBook = Nothing [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]    MsgBox "O arquivo foi exportado com sucesso! ", vbInformation, "Exportar arquivos" [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]End Sub[/FONT][/COLOR]
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?


I appreciate the help
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,223,786
Messages
6,174,546
Members
452,571
Latest member
MarExcelTips

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top