Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 681

How to convert delimited text file to excel

$
0
0
I would like to ask for help in making a .vbs script a code that will suite to my needs which will be shown in the link below.

http://www.makeuseof.com/tag/how-to-...-spreadsheets/

the link shows how i want to convert my delimited text into excel.

i do have a code but it does not put my data into columns in excel. all data are only in column 1 like the image below with the commas:

Attachment 95437

here is the code:

Option Explicit

Dim objUser, strExcelPath, objExcel, objSheet, _
objFSO, objFile, aline, aLines, irow, icol

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\testing.txt", _
ForReading)
strExcelPath = "C:\testing.xls"

' Bind to Excel object.
'On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Excel application not found."
Wscript.Quit
End If
On Error GoTo 0

objExcel.visible = true
objExcel.Workbooks.Add

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "testing"

aLines = split(objFile.ReadAll, vbnewline)
For irow = 1 to Ubound(aLines) + 1
aline = split(aLines(irow-1), vbTab)
for icol = 1 to Ubound(aline) + 1
objSheet.Cells(irow, icol).value = aline(icol-1)
Next ' icol
next ' irow






thank you very much.
Attached Images
 

Viewing all articles
Browse latest Browse all 681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>