Can anyone help me how to convert txt file to xls file? Any help will be highly appreciated. Thanks!
Asked
Active
Viewed 1,630 times
1 Answers
1
Convert XLS to CSV on command line
I guess the above works in reverse.
If you want to work with the data itself in VB6 (I assume you do because of the tag), see this code pinched from this thread:
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "C:\Documents and Settings\...\My Documents\My Database\Text;" & _
"Extended Properties=""Text;HDR=No;"""
rs.Open "Select * from TextFile.csv", cnn, adOpenStatic, adLockReadOnly, adCmdText
'...
'...
'...
rs.Close
cnn.Close
Set cnn = Nothing
CSV is a special case of TXT type where fields are comma-separated. You should be able to nominate any character including space or tab as the delimiter.
-
i got an error saying that user-defined type not define. What should i do? Do i need to include some refferences? – smith de jesus Jul 08 '11 at 07:37
-
at line 1, dim cnn as new ADODB.Connection – smith de jesus Jul 08 '11 at 07:41
-
You need [ADO](http://www.vb6.us/tutorials/database-access-ado-vb6-tutorial), have you [installed](http://support.microsoft.com/kb/168335) it? "To properly install ADO on your computer, you need to install MDAC." – spraff Jul 08 '11 at 07:45
-
what version of mdac do i need? – smith de jesus Jul 08 '11 at 07:56
-
Just go for whatever the current official download is. – spraff Jul 08 '11 at 07:58
-
do you have a vb6 program that convert excel to pdf? Thanks! – smith de jesus Jul 08 '11 at 08:05