Solved

Create *.cvs file, or xls from split array

Posted on 2008-10-11
5
837 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now