worksheet saveas question

S

shrek

Hi all,

I use the Excel from C++ via automation and I try use SaveAs method of the
WorkSheet object. The very strange thing is that it doesn't work with
"xlNormal" (that is -4143) or with "xlWorkbookNormal" (that is -4143 too) it
gives some back some error code (0x800a03ec). BUT is works with value 1
which is mentioned nowhere in the documentation or in the type library.

Can somebody tell me why "xlNormal" doesn't work with WorkSheet's SaveAs?
and what 1 means as file format constant? (it has to be some meaning because
Excel accept it)
 
J

Jim Rech

The sheet object does have a SaveAs method but I don't know why it exists
since it does the same thing as the workbook SaveAs method. It might be for
backward compatibility purposes.

I'd just use the workbook object and then you can use -4143. Btw, "1" is
not among the xlFileFormat named constants although it does seem to result
in a normal workbook.

--
Jim
| Hi all,
|
| I use the Excel from C++ via automation and I try use SaveAs method of the
| WorkSheet object. The very strange thing is that it doesn't work with
| "xlNormal" (that is -4143) or with "xlWorkbookNormal" (that is -4143 too)
it
| gives some back some error code (0x800a03ec). BUT is works with value 1
| which is mentioned nowhere in the documentation or in the type library.
|
| Can somebody tell me why "xlNormal" doesn't work with WorkSheet's SaveAs?
| and what 1 means as file format constant? (it has to be some meaning
because
| Excel accept it)
|
|
 
S

shrek

In fact this is not answer to my question bcz I knew these things before
too. You can use value 1 as fileformat constant in the SaveAs method of
worksheet object and it works but -4143 doesn't. Below a code snippet (
vbscript), it works with 1 and doesn't work with -4143. Can somebody tell me
why?

const FileFormat = 1
Set theArgs = wscript.Arguments
Set excelApp = Wscript.CreateObject("Excel.Application")
excelApp.Workbooks.Open(theArgs(0))
Set WrkSht = excelApp.Worksheets(1)
set range = wrksht.range("B1:D1")
range.select
excelApp.selection.mergecells = true
wrksht.SaveAs theArgs(1), FileFormat
excelApp.quit
set excalApp = nothing
 

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