Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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?"

Do you mean a VBA Macro which is run from Excel or a script running external to Excel?
Lionel Downunda (NZ)

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

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", 10The 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.

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.

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

![]() |
![]() |
![]() |

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