SaveCopyAs and not tabbing out generates 0x800a03ec

P

PromisedOyster

If I have a newly created Excel spreadsheet and I dont tab out of the
current cell and I call the SaveCopyAs method, then I get exception
0x800a03ec thrown.

Any ideas on how to avoid this?

(What the code is doing is saving the current Excel workbook into our
database).

Abridged sample code:


try
{
o =
System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
}
catch (System.Exception)
{
// Excel is not running
return;
}
_excelApp = o as Excel._Application;
// connect to current Excel workBook
_workBook = _excelApp.ActiveWorkbook;
if (_workBook == null)
{
// No workbook is currently defined
return;
}

_excelApp.DisplayAlerts = false;
_workBook.SaveCopyAs(excelFile);
 
C

Cindy M.

Hi PromisedOyster,
If I have a newly created Excel spreadsheet and I dont tab out of the
current cell and I call the SaveCopyAs method, then I get exception
0x800a03ec thrown.

Any ideas on how to avoid this?
Is it likely that the user is in "edit mode" (has typed something into a cell
but hasn't confirmed it)? I don't know of any way to get around this, but the
experts in the excel.programming newsgroup might. Try asking there, but don't
mention you're using .NET; just say the SaveCopyAs method results in an error
if the workbook is in editing mode, and ask if there's any way to
- determine that mode is activate and
- if it is, the best way to end the mode
(What the code is doing is saving the current Excel workbook into our
database).

Abridged sample code:


try
{
o =
System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
}
catch (System.Exception)
{
// Excel is not running
return;
}
_excelApp = o as Excel._Application;
// connect to current Excel workBook
_workBook = _excelApp.ActiveWorkbook;
if (_workBook == null)
{
// No workbook is currently defined
return;
}

_excelApp.DisplayAlerts = false;
_workBook.SaveCopyAs(excelFile);

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
P

PromisedOyster

Thanks Cindy

The user is definitely in edit mode. If they haven't made any changes
to the cell then no error is generated. Can I somehow force it to "end
edit"?
 
C

Cindy M.

Hi PromisedOyster,
The user is definitely in edit mode. If they haven't made any changes
to the cell then no error is generated. Can I somehow force it to "end
edit"?
As I said, ask in the excel.programming newsgroup. If there's a way to
force an exit from this mode, the experts there will know what it is.
You can try the DataEntryMode, but I'm not sure whether that's the right
thing...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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