Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Macro that stores all sheets as tab-delimited text files

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:= _
"H:\Develop\work\TestData\Testmodel.txt", FileFormat:= _
xlText, CreateBackup:=False
End Sub

But what I need is:
Sub GemAsTxt()
for all sheets:
ActiveWorkbook.SaveAs Filename:= _

"<directoryOfCurrentExcelFile\<excelfileWithoutFi leType\<sheetname",
FileFormat:= _
xlText, CreateBackup:=False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
Duke Carey
 
Posts: n/a
Default Macro that stores all sheets as tab-delimited text files

Doesn'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 & "\" & WorksheetFunction.Substitute(.Name, ".xls", "\")
For Each ws In .Worksheets
ws.SaveAs strPath & ws.Name & ".txt", xlTextWindows
Next
End With
End Sub



" wrote:

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:= _
"H:\Develop\work\TestData\Testmodel.txt", FileFormat:= _
xlText, CreateBackup:=False
End Sub

But what I need is:
Sub GemAsTxt()
for all sheets:
ActiveWorkbook.SaveAs Filename:= _

"<directoryOfCurrentExcelFile\<excelfileWithoutFi leType\<sheetname",
FileFormat:= _
xlText, CreateBackup:=False
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Macro that stores all sheets as tab-delimited text files

Thank you
I'll try it (-:
/Bjoern

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
How can I convert tab delimited files to pipe delimited? Jeremy Town Excel Discussion (Misc queries) 2 November 15th 07 04:29 PM
Insert text in a cell with a macro kayabob Excel Discussion (Misc queries) 5 June 22nd 05 05:43 PM
multiple text files URGENT tasha Excel Discussion (Misc queries) 1 December 19th 04 05:44 PM
importing multiple text files??? tashayu Excel Discussion (Misc queries) 0 December 19th 04 02:43 PM


All times are GMT +1. The time now is 04:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"