troubleshooting Question

Converting csv file to xls

Avatar of davidam
davidamFlag for Canada asked on
VB ScriptMicrosoft Excel
20 Comments1 Solution652 ViewsLast Modified:
We are using the following code to convert csv files to xls files
The problem is that sometimes the coversion fails to separate the data into individual cells and instead, puts all of the data into cell A1 of the newly created xls file...can we put something into line 5, the 'SaveAs' line,  to ensure that this does not happen?  (It should not matter but,  note that the new files are being created in Excel 2003, but the csv files may have been created with vba in either 03 or 07)
Thank you
Public Sub Convert_File(strCSVFile)
	xlApp.DisplayAlerts = False
	Set oCSVToConvert = xlApp.Workbooks.Open(strCSVFile, False, False)
	strConvertedName = Left(strCSVFile, Len(strCSVFile) - 4) & ".xls"
	oCSVToConvert.SaveAs strConvertedName, xlNormal
	oCSVToConvert.Close True
	xlApp.DisplayAlerts = True
	WScript.Sleep 1000
	objFSO.DeleteFile strCSVFile, True
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 20 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros