Computing.Net > Forums > Programming > Script Convert Excel SS to CSV

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Script Convert Excel SS to CSV

Reply to Message Icon

Name: bluedragon
Date: March 3, 2008 at 13:56:25 Pacific
OS: Window XP Pro
CPU/Ram: Centrino/2GB
Comment:

Hi,

I am fairly new at windows scripting, and am looking for some suggestion or code segments on how to go about writing a command line script to convert Excel SS to CSV files.

bd



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: March 3, 2008 at 17:33:52 Pacific
Reply:

I am fairly new at windows scripting
Natively, there's VBScript, JScript, and Command Script. Office adds VBA. That doesn't even include the alternatives, like Power Shell scripts and Perl. You need to narrow it down a bit.

Excel SS
I know I'm missing something simple here, but the only thought this prompts is, "What does the Secret Service have to do with Excel?"


0

Response Number 2
Name: Lionelnz
Date: March 3, 2008 at 20:32:44 Pacific
Reply:

Do you mean a VBA Macro which is run from Excel or a script running external to Excel?

Lionel Downunda (NZ)


0

Response Number 3
Name: bluedragon
Date: March 4, 2008 at 04:45:29 Pacific
Reply:

Thanks,

Basically, what I am trying to do is get the data from several 100 Excel Spreadsheets(SS) in a form that I can use it on a Unix platform. The catch is the only way the two system communicate is thru a firewall. I have the script for the unix half.

bd


0

Response Number 4
Name: Razor2.3
Date: March 4, 2008 at 18:59:54 Pacific
Reply:

Okay, to make this easy, I made this as a VBScript. It'll open every .xls file in the directory, then save it as <workbookName>.<sheetName>.csv:

Dim oFSO
Dim oShell, oExcel, oFile, oSheet
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
Set oExcel = CreateObject("Excel.Application")
oExcel.DisplayAlerts = False

For Each oFile In oFSO.GetFolder("C:\").Files
If LCase(oFSO.GetExtensionName(oFile)) = "xls" Then
With oExcel.Workbooks.Open(oFile, 0, True, , , , True, , , , False, , False)
For Each oSheet In .Worksheets
oSheet.SaveAs ".\" & oFile.Name & "." & oSheet.Name, 6
Next
.Close False, , False
End With
End If
Next
oExcel.Quit
oShell.Popup "Conversion complete", 10

The first red part (the C:\) is where the script will look for files.
The second red part (the .) is where the script will save the sheets.


0

Response Number 5
Name: FishMonger
Date: March 4, 2008 at 19:02:59 Pacific
Reply:

Have you tried to copy the files to the unix box and work with them directly instead of converting to csv files?

You didn't specify the type of script you're using, but Perl (which can be run on either system) can read/write MS Excel files.


0

Related Posts

See More



Response Number 6
Name: bluedragon
Date: March 5, 2008 at 04:43:53 Pacific
Reply:

Perl was my first choice but the problem with the firewall it will only allow certian file types thru. And xls files are not one of them. That left me with waht Razor2.3 has graciously provided.

Thanks for the help


bd


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Script Convert Excel SS to CSV

convert excel file to grpah www.computing.net/answers/programming/convert-excel-file-to-grpah/14349.html

Link Excel SS to html page and back www.computing.net/answers/programming/link-excel-ss-to-html-page-and-back/6089.html

VB Script and Excel - Sheet Names www.computing.net/answers/programming/vb-script-and-excel-sheet-names/3845.html