Hi!
I'm trying to write an macro that converts one single xls-file
to multiple text file (tab delimited) with filenames corrsponding to
the names of the sheets.
How to do that?
I recorded my actions:
Sub GemAsTxt()
ActiveWorkbook.SaveAs Filename:= _
quot;H:\Develop\work\TestData\Testmodel.txtquot;, FileFormat:= _
xlText, CreateBackup:=False
End Sub
But what I need is:
Sub GemAsTxt()
for all sheets:
ActiveWorkbook.SaveAs Filename:= _
quot;lt;directoryOfCurrentExcelFilegt;\lt;excelfileWithoutFi leTypegt;\lt;sheetnamegt;quot;,
FileFormat:= _
xlText, CreateBackup:=False
End SubDoesn't work unless a directory matching the name of the workbook (without
the .xls) already exists
Sub SaveEm()
Dim strPath As String
Dim ws As Worksheet
With ActiveWorkbook
strPath = .Path amp; quot;\quot; amp; WorksheetFunction.Substitute(.Name, quot;.xlsquot;, quot;\quot;)
For Each ws In .Worksheets
ws.SaveAs strPath amp; ws.Name amp; quot;.txtquot;, xlTextWindows
Next
End With
End Sub
quot; wrote:
gt; Hi!
gt; I'm trying to write an macro that converts one single xls-file
gt; to multiple text file (tab delimited) with filenames corrsponding to
gt; the names of the sheets.
gt;
gt; How to do that?
gt;
gt; I recorded my actions:
gt; Sub GemAsTxt()
gt; ActiveWorkbook.SaveAs Filename:= _
gt; quot;H:\Develop\work\TestData\Testmodel.txtquot;, FileFormat:= _
gt; xlText, CreateBackup:=False
gt; End Sub
gt;
gt; But what I need is:
gt; Sub GemAsTxt()
gt; for all sheets:
gt; ActiveWorkbook.SaveAs Filename:= _
gt;
gt; quot;lt;directoryOfCurrentExcelFilegt;\lt;excelfileWithoutFi leTypegt;\lt;sheetnamegt;quot;,
gt; FileFormat:= _
gt; xlText, CreateBackup:=False
gt; End Sub
gt;
gt;
Thank you
I'll try it (-:
/Bjoern
- Dec 18 Mon 2006 20:34
Macro that stores all sheets as tab-delimited text files
close
全站熱搜
留言列表
發表留言