Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Basic macro ? I'm new to this.

Hey there, I am trying to write a macro that will export
excel worksheets to tab delimited text files. If I go to
File and Saveas I can save the worksheet fine but not the
whole work book. Does anyone know of a way I can write a
macro to select all the worksheets and export them all to
a text file? Or perhaps multiple text files, you know
one for each sheet? Any help would be greatly
appreciated. I'm new to this whole thing and it is
harder than I thought it would be. Thanks a bunch!
Mad love, Kate.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Basic macro ? I'm new to this.

Hi Katie,

Simplest way is to copy the worksheets one at a time to a new workbook
(right-click on the sheet tab to get a menu), and then save these as text
files. No macro.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Katie" wrote in message
...
Hey there, I am trying to write a macro that will export
excel worksheets to tab delimited text files. If I go to
File and Saveas I can save the worksheet fine but not the
whole work book. Does anyone know of a way I can write a
macro to select all the worksheets and export them all to
a text file? Or perhaps multiple text files, you know
one for each sheet? Any help would be greatly
appreciated. I'm new to this whole thing and it is
harder than I thought it would be. Thanks a bunch!
Mad love, Kate.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Basic macro ? I'm new to this.

You could try something along the lines of:


Sub SaveWorksheets()
'
' This code will save each worksheet as a .csv file with a filename
' which is the same as the worksheet name
'

Dim ws As Worksheet
Dim strFileName As String

For Each ws In Worksheets
strFileName = ws.Name & ".csv"
ActiveWorkbook.SaveAs FileName:=strFileName, FileFormat:=xlCSV,
CreateBackup:=False
Next
End Sub



Hope this helps.


Katie wrote:

Hey there, I am trying to write a macro that will export
excel worksheets to tab delimited text files. If I go to
File and Saveas I can save the worksheet fine but not the
whole work book. Does anyone know of a way I can write a
macro to select all the worksheets and export them all to
a text file? Or perhaps multiple text files, you know
one for each sheet? Any help would be greatly
appreciated. I'm new to this whole thing and it is
harder than I thought it would be. Thanks a bunch!
Mad love, Kate.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Basic macro ? I'm new to this.

mea culpa. You wanted text file not csv....

Sub SaveWorksheets()
'
' This code will save each worksheet as a .txt file with a filename
' which is the same as the worksheet name
'

Dim ws As Worksheet
Dim strFileName As String

For Each ws In Worksheets
strFileName = ws.Name & ".txt"
ActiveWorkbook.SaveAs FileName:=strFileName, FileFormat:=xlTxt,
CreateBackup:=False
Next
End Sub



:-D


SmilingPolitely wrote:

You could try something along the lines of:


Sub SaveWorksheets()
'
' This code will save each worksheet as a .csv file with a filename
' which is the same as the worksheet name
'

Dim ws As Worksheet
Dim strFileName As String

For Each ws In Worksheets
strFileName = ws.Name & ".csv"
ActiveWorkbook.SaveAs FileName:=strFileName, FileFormat:=xlCSV,
CreateBackup:=False
Next
End Sub



Hope this helps.


Katie wrote:

Hey there, I am trying to write a macro that will export excel
worksheets to tab delimited text files. If I go to File and Saveas I
can save the worksheet fine but not the whole work book. Does anyone
know of a way I can write a macro to select all the worksheets and
export them all to a text file? Or perhaps multiple text files, you
know one for each sheet? Any help would be greatly appreciated. I'm
new to this whole thing and it is harder than I thought it would be.
Thanks a bunch! Mad love, Kate.




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
hopefully a basic macro MelB Excel Discussion (Misc queries) 6 November 18th 07 03:10 AM
Basic Macro Help [email protected] Excel Discussion (Misc queries) 1 June 7th 07 09:13 PM
Basic Macro Query luvthavodka Excel Discussion (Misc queries) 2 January 4th 07 12:33 AM
Very very basic macro help Mr. Smiley Excel Discussion (Misc queries) 2 September 8th 05 08:12 PM
Visual Basic Macro negzel Excel Discussion (Misc queries) 1 December 28th 04 10:53 PM


All times are GMT +1. The time now is 05:37 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"