ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Command Line Export (https://www.excelbanter.com/excel-discussion-misc-queries/140012-command-line-export.html)

fjurek

Command Line Export
 
I need to export a sheet to a file in a tab-separated format, to use in a bat
script.
How do I do that ? Is it possible ? Are there any tools ?

Regards

Jurek

joel

Command Line Export
 
You can save a workbook with only one worksheet as a csv file by using the
File -Save As menu option and selectt .csv format. These are text files
which can be read by other programs.

"fjurek" wrote:

I need to export a sheet to a file in a tab-separated format, to use in a bat
script.
How do I do that ? Is it possible ? Are there any tools ?

Regards

Jurek


David Biddulph[_2_]

Command Line Export
 
The OP said he wanted TAB-separated, not COMMA-separated.

Joel is right in his answer as far as File/ Save As, but at that stage one
of the .txt options is TAB-separated.
--
David Biddulph

"Joel" wrote in message
...
You can save a workbook with only one worksheet as a csv file by using the
File -Save As menu option and selectt .csv format. These are text files
which can be read by other programs.

"fjurek" wrote:

I need to export a sheet to a file in a tab-separated format, to use in a
bat
script.
How do I do that ? Is it possible ? Are there any tools ?

Regards

Jurek




joel

Command Line Export
 
You can always replace tabs with spaces using notepad once the file is saved.
Hopefully there is not commas in the cell data.

"David Biddulph" wrote:

The OP said he wanted TAB-separated, not COMMA-separated.

Joel is right in his answer as far as File/ Save As, but at that stage one
of the .txt options is TAB-separated.
--
David Biddulph

"Joel" wrote in message
...
You can save a workbook with only one worksheet as a csv file by using the
File -Save As menu option and selectt .csv format. These are text files
which can be read by other programs.

"fjurek" wrote:

I need to export a sheet to a file in a tab-separated format, to use in a
bat
script.
How do I do that ? Is it possible ? Are there any tools ?

Regards

Jurek





joel

Command Line Export
 
There is also a Tab delimited text option in the SAve As choices.

"David Biddulph" wrote:

The OP said he wanted TAB-separated, not COMMA-separated.

Joel is right in his answer as far as File/ Save As, but at that stage one
of the .txt options is TAB-separated.
--
David Biddulph

"Joel" wrote in message
...
You can save a workbook with only one worksheet as a csv file by using the
File -Save As menu option and selectt .csv format. These are text files
which can be read by other programs.

"fjurek" wrote:

I need to export a sheet to a file in a tab-separated format, to use in a
bat
script.
How do I do that ? Is it possible ? Are there any tools ?

Regards

Jurek





fjurek

Command Line Export
 
Thank you all.
This is all true, and I use it on single files, but I need to use it on many
files and for other manipulations on these data, so I want to have it in a
bat file, and the export should work from the command line or script.

Yours

Jurek


"Joel" wrote:

There is also a Tab delimited text option in the SAve As choices.

"David Biddulph" wrote:

The OP said he wanted TAB-separated, not COMMA-separated.

Joel is right in his answer as far as File/ Save As, but at that stage one
of the .txt options is TAB-separated.
--
David Biddulph

"Joel" wrote in message
...
You can save a workbook with only one worksheet as a csv file by using the
File -Save As menu option and selectt .csv format. These are text files
which can be read by other programs.

"fjurek" wrote:

I need to export a sheet to a file in a tab-separated format, to use in a
bat
script.
How do I do that ? Is it possible ? Are there any tools ?

Regards

Jurek





joel

Command Line Export
 
Thsi macro will automatically write TAB text

Sub WriteTab()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const MyPath = "C:\temp\"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

MyTAB = Chr(9)


Set fswrite = CreateObject("Scripting.FileSystemObject")


WriteFileName = "tabtext.txt"


WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)


LastRow = Rows.Count
Do While (Cells(LastRow, Columns.Count).End(xlToLeft).Column = 1) And _
IsEmpty(Cells(LastRow, 1))

LastRow = LastRow - 1
Loop

For RowCount = 1 To LastRow

LastColumn = Cells(RowCount, Columns.Count).End(xlToLeft).Column
For ColCount = 1 To LastColumn

If ColCount = 1 Then
OutputLine = Cells(RowCount, ColCount)
Else
OutputLine = OutputLine + MyTAB + CStr(Cells(RowCount, ColCount))
End If


Next ColCount

tswrite.WriteLine OutputLine
Next RowCount

tswrite.Close

End Sub


"fjurek" wrote:

Thank you all.
This is all true, and I use it on single files, but I need to use it on many
files and for other manipulations on these data, so I want to have it in a
bat file, and the export should work from the command line or script.

Yours

Jurek


"Joel" wrote:

There is also a Tab delimited text option in the SAve As choices.

"David Biddulph" wrote:

The OP said he wanted TAB-separated, not COMMA-separated.

Joel is right in his answer as far as File/ Save As, but at that stage one
of the .txt options is TAB-separated.
--
David Biddulph

"Joel" wrote in message
...
You can save a workbook with only one worksheet as a csv file by using the
File -Save As menu option and selectt .csv format. These are text files
which can be read by other programs.

"fjurek" wrote:

I need to export a sheet to a file in a tab-separated format, to use in a
bat
script.
How do I do that ? Is it possible ? Are there any tools ?

Regards

Jurek





All times are GMT +1. The time now is 11:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com