Link to home
Start Free TrialLog in
Avatar of mmitchell57
mmitchell57

asked on

Create *.cvs file, or xls from split array

Through the help of this forum I've managed to make a VBScript that sucks in a txt file, parses it up, and spits out some legible data. I have it spit out a file that's in *.cvs format. The problem I have is that the file is not automatically picked up by Excel as an associated file. If I create a file w/ Excel and save it as *.cvs it does. I'm not sure what i'm not doing right. Do I need to write some special data to the file for the association to work?  Below is the code i've gotten working and doing exactly what I want, minus the Excel association. :)  
Set objFSO = CreateObject("Scripting.FileSystemObject") 'object to first file
Const intForReading = 1
 
strFile1 = "Text.txt"        						'Read file location, name
strFile2 = "Disabled.cvs"    						'write file location, name
 
Set objFile1 = objFSO.OpenTextFile(strFile1, intForReading, False)
arr1 = Split(objFile1.ReadAll, VbCrLf)  				'bring file into array
objFile1.Close 								'closes objec to read file
									
cnt = ubound(arr1)							'sets count to array length
 									
Set objFile2 = objFSO.CreateTextFile(strFile2, True)			'object for write file
for i=0 to cnt 								'loop for writing
	arr2 = Split(arr1(i), "=")
	arr3 = Split(arr2(1), ",")
						
	objFile2.WriteLine arr3(0)					'writes to file
									'increments array count
Next
 
objFile2.Close
 
MsgBox "Done"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave
Dave
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmitchell57
mmitchell57

ASKER

oh heck.... attention to detail? :D
Yep, i'm retarded. Thank you! :)
I failed to pay attention to detail! I appreciate BrettDJ being polite w/ his response.
:)

wev'e all been there

Cheers

Dave