Computing.Net > Forums > Programming > Extract an excel page to a txt file

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.

Extract an excel page to a txt file

Reply to Message Icon

Name: DarrenPearce
Date: October 2, 2008 at 01:39:38 Pacific
OS: WinXP
CPU/Ram: Intel Core2duo 4gb
Product: Dell
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: October 2, 2008 at 02:57:21 Pacific
Reply:

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......


0

Response Number 2
Name: Razor2.3
Date: October 2, 2008 at 19:38:30 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: Extract an excel page to a txt file

Ping list of computers from a txt file www.computing.net/answers/programming/ping-list-of-computers-from-a-txt-file/19843.html

batch to edit a txt file www.computing.net/answers/programming/batch-to-edit-a-txt-file/15327.html

Extract Values from a txt file www.computing.net/answers/programming/extract-values-from-a-txt-file/17728.html