Excel SaveAs "TXT" file

Excel SaveAs "TXT" file

Anonymous
Not applicable
365 Views
5 Replies
Message 1 of 6

Excel SaveAs "TXT" file

Anonymous
Not applicable
I'd like to open and excel file and save it as a text file using VBA. I
know how to open the file and saveas ".txt", but it's still the Excel "XLS"
format. What I really want is to save it to a ".txt" file with TAB
delimitation. Does anyone know how to do this? I would appreciate any help
to push me in the right direction.

Thanks,
JC
0 Likes
366 Views
5 Replies
Replies (5)
Message 2 of 6

arcticad
Advisor
Advisor
save the file as a cvs file
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 6

Anonymous
Not applicable
you need to specify the file format after specifying the filename ~ just specifying a file name is not enough
e.g.
XL.ActiveSheet.SaveAs "C:\data\myfile.csv", xlCSV
will save as CSV format ~ I can't remember what the Text version is offhand, it may be xlUnicodeText

http://www.resourcecad.com ~ for your CAD solutions
0 Likes
Message 4 of 6

Anonymous
Not applicable
To save as Tab Delimited just seperate your values with
a Tab.

Private Sub stub()
Dim txtTab As Integer: txtTab = FreeFile
Open "c:\TabDelimited.txt" For Output As #txtTab
Print #txtTab, "1" & vbTab & "2" & vbTab
Close #txtTab
End Sub

Replace vbTab with "," and give file a .csv ext for
csv file type.

gl Paul
0 Likes
Message 5 of 6

Anonymous
Not applicable
why write all the tabs manually when the saveas will do it automatically for you ? you are just creating unnecessary work for your self
0 Likes
Message 6 of 6

Anonymous
Not applicable
use this method if your not in Excel VBA...
0 Likes