Library code snippets
Converting an Excel file to Tab Delimited Format
By Vipin Mohandas, published on 07 Feb 2004
This code will convert an Excel file to tab delimited format, using the Excel object model (which will require Excel to be installed where this code is run!).
Dim lobjExcel As Object ' Instance Of The Excel Application Object
Dim lobjWorkBook As Object 'Instance For WorkBook Collection
Set lobjExcel = server.CreateObject("Excel.Application")
Set lobjWorkBook = lobjExcel.Workbooks.Open(Filename with the path)
lobjExcel.DisplayAlerts = False
'Saving In The Tab Delimited Format
lobjWorkBook.SaveAs lstrFilePath, -4158
lobjWorkBook.Close
Set lobjWorkBook = Nothing
'DesTroying The Excel Object
lobjExcel.Quit
lobjExcel = Nothing
Related articles
Related discussion
-
Excel 2007 Error : ' the digital signature is deleted when Excel users tries to save the Master Excel Spreadsheet.'
by jdierkes (0 replies)
-
Excel VBA transposition problem
by KDHTSVAU (2 replies)
-
excell question
by Uncle (11 replies)
-
Question about subforms
by ginwah (0 replies)
-
How to change a position of a "line" control in a form based on combo box selection? Please help!!!
by scorpions111 (1 replies)
This -4158 reference is pretty bad practice.
If you have added the Excel Object Model to your projects, then you should use the predefined constants for fileformat.
Thse appear as a drop down set of options when you just type in
XlFileFormat.
-4158 is the actual value of XLFileFormat.xlCurrentPlatformText
Other values are:
xlCSV (which has a value of 6)
xlHTML (value 44)
but the point is if the code had actually said xlCurrentPlatformText instead of -4158, then many of the messages asking 'where did you get that number from?' would not have been posted.
You can find the constants available from any object library by pressing F2 and examining the object model there.
Guys i need help in tab delimited format... im a newbieand ,i dont have any idea in this thing.. can someone post a visual basic program code that uses "tab delimited "or a .txt file in storing data...
Name Age Address
xxxx xx xxxxxxxxxxxxx
xxxx xx xxxxxxxx
i want to learn how to save data, get data, update data..
i need to learn this because saving and getting records into a txt file will reduce processing time....
Thank you so much...hoping for ur reply...thankz...XP
Hi Vipin,
Thanks for the great piece of code. Just a hint can you let people know that in the code where you've placed the word
lobjWorkBook.SaveAs lstrFilePath, -4158
'lstrFilePath' is the name of the output txt file.
Thanks for helping me out your a super-hero!
Eddy
This thread is for discussions of Converting an Excel file to Tab Delimited Format.