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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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
 
Upvote 0

Forum statistics

Threads
1,213,529
Messages
6,114,155
Members
448,554
Latest member
Gleisner2

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
Back
Top