I have a script that starts up Excel, opens a CSV file, does a bunch of
stuff to the contents, and then I want to save the results as a normal Excel
workbook. Everything works great except the SaveAs part.

Here is the line:

objExcel.ActiveWorkbook.SaveAs "Foobar.xls", xlNormal

The error is "SaveAs method of Workbook class failed"

I've tried a number of random variations on the theme, to no avail.

Any suggestions would be greatfully received. Thanks!

Re: Excel SaveAs Fileformat by y

y
Sat Apr 08 23:49:48 CDT 2006

"MichaelHensley" <mhensley@news.postalias> wrote in message
news:euwlY64WGHA.4148@TK2MSFTNGP03.phx.gbl...
>I have a script that starts up Excel, opens a CSV file, does a bunch of
>stuff to the contents, and then I want to save the results as a normal
>Excel workbook. Everything works great except the SaveAs part.
>
> Here is the line:
>
> objExcel.ActiveWorkbook.SaveAs "Foobar.xls", xlNormal
>
> The error is "SaveAs method of Workbook class failed"
>
In VBS you can't use named constant.
(Only allowed vbCRLF etc.)
If you want to save as CSV must write like this.

Const xlCSV=6
objExcel.ActiveWorkbook.SaveAs "Foobar.xls", xlCSV

y sakuda from JPN


Re: Excel SaveAs Fileformat by MichaelHensley

MichaelHensley
Sun Apr 09 00:04:51 CDT 2006

y sakuda pointed out:

> In VBS you can't use named constant.
> (Only allowed vbCRLF etc.)
> If you want to save as CSV must write like this.
>
> Const xlCSV=6
> objExcel.ActiveWorkbook.SaveAs "Foobar.xls", xlCSV

Got it, thanks!

Note: for those playing along at home, it looks like the value for
"xlNormal" is 1.



Re: Excel SaveAs Fileformat by y

y
Sun Apr 09 00:39:32 CDT 2006

"MichaelHensley" <mhensley@news.postalias> wrote in message
news:ukPwjM5WGHA.4976@TK2MSFTNGP03.phx.gbl...
> Note: for those playing along at home, it looks like the value for
> "xlNormal" is 1.
>
Sorry. I misread as you want to Save as CSV.
If you want to save as current version, you don't need to
specify second parameter.
objExcel.ActiveWorkbook.SaveAs "Foobar.xls"

y sakuda from JPN