Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All
I have a spreadsheet with 7 worksheets. I would like to automate extracting just one of these worksheets (worksheet's name is "storeline") to a txt file. The format of the data of this worksheet is exactly how I need it. The data changes daily, so would like to drive this via a batch file that will run nightly. Can anyone assist with an example batch or some help to get this going.
Much appreciated in advance
Darren

Before you can do almost and batch processing you would need to convert the spread sheet into plain text/csl/csv. There *may* be a console application to do this that could be used from a batch file; I don't know of any such uilities off hand.
Batch files run on a limited character set, an inheritance from DOS systems. Because xls,xslx ect. use binary data not properly expressible in batch scripting it is almost impossible to parse. A good example of this is trying to use the for /f command on an executable file, or any binary file for that matter, the command flat out fails, it won't even try or set an erorlevel it "just don't work"
If you find an easy way to convert the files then it may work. You may find another programming language more useful for your purposes......

Batch, no. VBScript, however, can interface with Excel directly.
This will save the sheet as a .CSV file:
Option Explicit
If WScript.Arguments.Count = 0 Then
MsgBox "Nothing to do", 16, "Error"
WScript.Quit 1
End If
With GetObject(WScript.Arguments(0))
.Sheets("storeline").SaveAs .Path & "\exported", 6
End With
WScript.Echo "Done"EDIT: Save this as a .VBS, then drag-and-drop the workbook in question on the .VBS icon.

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

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