Solved

Create *.cvs file, or xls from split array

Posted on 2008-10-11
5
841 Views
Last Modified: 2010-04-21
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

0
Comment
Question by:mmitchell57
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 50

Accepted Solution

by:
Dave Brett earned 250 total points
ID: 22695911
try a csv file
strFile2 = "Disabled.csv"
0
 

Author Comment

by:mmitchell57
ID: 22695931
oh heck.... attention to detail? :D
0
 

Author Comment

by:mmitchell57
ID: 22695932
Yep, i'm retarded. Thank you! :)
0
 

Author Closing Comment

by:mmitchell57
ID: 31505380
I failed to pay attention to detail! I appreciate BrettDJ being polite w/ his response.
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 22695956
:)

wev'e all been there

Cheers

Dave
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question