Save Excel File into a Tab-Delimited File - by MACRO

Robb

Board Regular
Joined
Feb 17, 2002
Messages
145
I need to save an excel file into a Tab-Delimited file...programmatically. This needs to be done so Unix can read the file and do wonderful things with the data.

I use an Excel WB to Open a file that the user would like to format. Once the formatting is done I need to close the file but save it as a tab-delimited file in a different location - all without user intervention. I don't need to save the changes on the original Excel file.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Mark O'Brien

MrExcel MVP
Joined
Feb 15, 2002
Messages
3,530
Something as simple as this would work:

<pre>
Option Explicit


Private Sub SaveAsTabDelimited(ByVal sFileName As String)
With ActiveWorkbook
.SaveAs Filename:=sFileName, FileFormat:=xlText, CreateBackup:=False
End With
End Sub

Public Sub test()
SaveAsTabDelimited "C:TempBook2.txt"
ActiveWorkbook.Close savechanges:=False
End Sub</pre>

You might want to add something that makes sure the filename is unique though.

HTH
 

Robb

Board Regular
Joined
Feb 17, 2002
Messages
145
Thanx Mark, works like a charm. Funny how sometimes we over analyze things.
 

Forum statistics

Threads
1,181,643
Messages
5,931,188
Members
436,780
Latest member
doknights

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top