Are there command line parameters for Excel?

G

Guest

I am looking for a way from a batch file to start excel to open a specific
xls file and then save it in tab delimited text format and then close the new
..txt file.
I have a PERL script that requires the file to be in the .txt format in
order to parse it.
I have many files that require this operation and it would be easier to
drive this process with this type of functionality.
 
S

Steve Yandl

Michael,

The example below is a vbScript that would open the xls file
"C:\Test\RawTable.xls", save it as a csv file named "C:\Temp\RawTable.txt"
and then convert the csv file to a tab delimited file with the same name,
"C:\Temp\RawTable.txt" and finally close the txt file.

_____________________

Const xlCSV = 6
Const xlDoNotSaveChanges = 2
Const ForReading = 1
Const ForWriting = 2

' Open the Excel file and save a copy as a CSV file

Set objExcel = CreateObject("Excel.Application")

Set objWkbk = objExcel.Workbooks.Open("C:\Test\RawTable.xls")

objExcel.DisplayAlerts = False

objWkbk.SaveAs "C:\Temp\RawTable.txt", xlCSV
objWkbk.Close xlDoNotSaveChanges

objExcel.DisplayAlerts = True
objExcel.Quit


' Open the CSV file and convert to a tab delimited file

Set FSO = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.OpenTextFile("C:\Temp\RawTable.txt", ForReading)
strContents = objFile.ReadAll
objFile.Close
strContents = Replace(strContents, ",", vbTab)
Set objFile = FSO.OpenTextFile("C:\Temp\RawTable.txt", ForWriting)
objFile.Write StrContents
objFile.Close


______________________

Steve Yandl
 
G

Gord Dibben

Stan

You could always use Excel Help on "startup switches"


Gord Dibben MS Excel MVP
 
D

David Biddulph

Stan Brown said:
Wed, 1 Aug 2007 12:30:03 -0700 from Joel
Unfortunately, arrogant Microsoft won't display that page because I'm
using a real browser instead of Internet Explorer. There was
something about checking to see whether I have Office 2007 -- itself
pretty darn arrogant.

I don't know which real browser you were using, but that page will display
in Mozilla's Firefox.
 
S

Stan Brown

Sat, 04 Aug 2007 19:13:35 -0700 from <Gord Dibben
You could always use Excel Help on "startup switches"

Agreed, and in fact that's how I got the information when I was
looking for it a few months ago.

But I am just agog at the barriers Microsoft puts up to getting
information from its Web site. There seems no good reason for it.
 
S

Stan Brown

Sun, 5 Aug 2007 09:11:42 +0100 from <"David Biddulph" <groups [at]
biddulph.org.uk>>:
I don't know which real browser you were using, but that page will
display in Mozilla's Firefox.

The real browser I'm using is Mozilla. As I mentioned, it just
displayed a page saying Microsoft was checking whether I have Office
2007, and stuck there.
 
D

Dallman Ross

Stan Brown said:
Sun, 5 Aug 2007 09:11:42 +0100 from <"David Biddulph" <groups
[at] biddulph.org.uk>>:
I don't know which real browser you were using, but that page
will display in Mozilla's Firefox.

The real browser I'm using is Mozilla. As I mentioned, it just
displayed a page saying Microsoft was checking whether I have
Office 2007, and stuck there.

I don't have Office 2007, do use Firefox, and had zero trouble
looking at that page, even when i declined cookies. No problems
at all. It's a useful page.

Microsoft does lots one could criticize, but this seems not to be one
of them.
 
S

Stan Brown

Sun, 5 Aug 2007 13:47:04 +0000 (UTC) from Dallman Ross
I don't have Office 2007, do use Firefox, and had zero trouble
looking at that page, even when i declined cookies. No problems
at all. It's a useful page.

Microsoft does lots one could criticize, but this seems not to be one
of them.

(shrugs) Well, I guess this is just an unsolved mystery. It's not the
first time it has happened. If I were more motivated I'd dig into the
headers and the page source and try to figure out what's going on.
But since the chance Microsoft will heed my trouble report is pretty
darn slim, it would be a waste of effort.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top