Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save Worksheet at .txt


Hello. I would like a macro to save a worksheet as a .csv file in
folder on my C drive. The worksheet will vary in size (rows an
columns). The sheet must use tabs as a delimiter.

Thanks for your help

--
Sandema
-----------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...fo&userid=3244
View this thread: http://www.excelforum.com/showthread.php?threadid=52922

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Save Worksheet at .txt

A CSV file uses commas as delimiters

Activesheet.copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "C:\Myfolder\Myfile.txt", xlText
Application.DisplayAlerts = True
Activeworkbook.Close SaveChanges:=False

--
Regards,
Tom Ogilvy

"Sandeman" wrote:


Hello. I would like a macro to save a worksheet as a .csv file in a
folder on my C drive. The worksheet will vary in size (rows and
columns). The sheet must use tabs as a delimiter.

Thanks for your help!


--
Sandeman
------------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
View this thread: http://www.excelforum.com/showthread...hreadid=529220


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save Worksheet at .txt


Thanks Tom. Doesn't appear to work though as I get an error statin
some of the cells contain more than 255 characters, which stops th
macro in its tracks. Is there a workaround or another option

--
Sandema
-----------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...fo&userid=3244
View this thread: http://www.excelforum.com/showthread.php?threadid=52922

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Save Worksheet at .txt

Maybe

Dim wks As Worksheet
Dim newWks As Worksheet

Set wks = ActiveSheet
wks.Copy
Set newWks = ActiveSheet
wks.Cells.Copy
newWks.Range("a1").PasteSpecial Paste:=xlPasteValues

Application.DisplayAlerts = False
newWks.Parent.SaveAs "C:\Myfile.txt", xlText
Application.DisplayAlerts = True
newWks.Parent.Close SaveChanges:=False



Sandeman wrote:

Thanks Tom. Doesn't appear to work though as I get an error stating
some of the cells contain more than 255 characters, which stops the
macro in its tracks. Is there a workaround or another option?

--
Sandeman
------------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
View this thread: http://www.excelforum.com/showthread...hreadid=529220


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save Worksheet at .txt


That's the ticket. Thanks Dave

--
Sandema
-----------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...fo&userid=3244
View this thread: http://www.excelforum.com/showthread.php?threadid=52922

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
How do I save only active worksheet without save all of worksheet droth Excel Worksheet Functions 2 February 21st 09 05:11 PM
When you hit Save on a template, how can you save as worksheet? cwgirl1982 Excel Worksheet Functions 1 September 4th 08 11:18 PM
'Save current worksheet'; 'Open next worksheet' - two command buttons englishmustard Excel Discussion (Misc queries) 1 April 7th 06 12:54 PM
Save As - changes worksheet name JTF Excel Programming 2 August 17th 05 07:01 PM
Worksheet Buttons (Save, Save As, Cut, Paste, etc.) Not Working SuzieQ12345 Excel Worksheet Functions 5 January 21st 05 02:57 PM


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