Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I regularily work with workbooks that contain well over 20 worksheets per
book. After working with the data I always have to save each 'sheet' as an individual *.txt file. All the sheets are saved using the worksheet name. Is there any way to automate this process, ie. save all worksheets to a respective *.txt file. For example, 20 sheets in a book, will result in 20 seperate *.txt files. Steve |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You could use a macro:
Option Explicit Sub Testme02() Dim Wks As Worksheet For Each Wks In ActiveWorkbook.Worksheets Wks.Copy 'to a new workbook With ActiveSheet 'the new sheet in the new workbook .Parent.SaveAs Filename:="C:\temp\" & .Name & ".txt", _ FileFormat:=xlTextWindows .Parent.Close savechanges:=False End With Next Wks End Sub If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm This also assumes that the worksheet names are valid OS names and that the C:\Temp folder already exists. stevieb wrote: I regularily work with workbooks that contain well over 20 worksheets per book. After working with the data I always have to save each 'sheet' as an individual *.txt file. All the sheets are saved using the worksheet name. Is there any way to automate this process, ie. save all worksheets to a respective *.txt file. For example, 20 sheets in a book, will result in 20 seperate *.txt files. Steve -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I think the code you wrote is a little to complicated for the task. I dont
see why you cant traverse through the active workbook, and just save each file. Would it possible to do that instead of making a new workbook each time? "Dave Peterson" wrote: You could use a macro: Option Explicit Sub Testme02() Dim Wks As Worksheet For Each Wks In ActiveWorkbook.Worksheets Wks.Copy 'to a new workbook With ActiveSheet 'the new sheet in the new workbook .Parent.SaveAs Filename:="C:\temp\" & .Name & ".txt", _ FileFormat:=xlTextWindows .Parent.Close savechanges:=False End With Next Wks End Sub If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm This also assumes that the worksheet names are valid OS names and that the C:\Temp folder already exists. stevieb wrote: I regularily work with workbooks that contain well over 20 worksheets per book. After working with the data I always have to save each 'sheet' as an individual *.txt file. All the sheets are saved using the worksheet name. Is there any way to automate this process, ie. save all worksheets to a respective *.txt file. For example, 20 sheets in a book, will result in 20 seperate *.txt files. Steve -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If you go through the sheets in the active workbook and save each as a .txt
file, watch what happens to the filename each time you do the save. Or just look at the filename after the last worksheet has been saved. It's much easier to avoid the problem than to work around it (in my opinion). stevieb wrote: I think the code you wrote is a little to complicated for the task. I dont see why you cant traverse through the active workbook, and just save each file. Would it possible to do that instead of making a new workbook each time? "Dave Peterson" wrote: You could use a macro: Option Explicit Sub Testme02() Dim Wks As Worksheet For Each Wks In ActiveWorkbook.Worksheets Wks.Copy 'to a new workbook With ActiveSheet 'the new sheet in the new workbook .Parent.SaveAs Filename:="C:\temp\" & .Name & ".txt", _ FileFormat:=xlTextWindows .Parent.Close savechanges:=False End With Next Wks End Sub If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm This also assumes that the worksheet names are valid OS names and that the C:\Temp folder already exists. stevieb wrote: I regularily work with workbooks that contain well over 20 worksheets per book. After working with the data I always have to save each 'sheet' as an individual *.txt file. All the sheets are saved using the worksheet name. Is there any way to automate this process, ie. save all worksheets to a respective *.txt file. For example, 20 sheets in a book, will result in 20 seperate *.txt files. Steve -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I save an individual page in a workbook? | Excel Worksheet Functions | |||
MACRO HELP: Save All Sheets To Individual Workbooks | Excel Discussion (Misc queries) | |||
Create individual files from a row | Excel Discussion (Misc queries) | |||
Help importing text files into individual cells | Excel Discussion (Misc queries) | |||
How can I make Excel Files save as the text appers in a cell, can. | Excel Discussion (Misc queries) |