COM Exception while setting ExcelApp.DisplayAlerts

Add-in Express™ Support Service
That's what is more important than anything else

COM Exception while setting ExcelApp.DisplayAlerts
 
Lakshman Kumar


Guest


Hi,

Recently I faced the issue in List separator while saving csv file and fixed the issue as mentioned in https://www.add-in-express.com/forum/read.php?FID=5&TID=15587.

But the same code now causing COM Exception 0x800A03EC at Microsoft.Office.Interop.Excel._Application.set_DisplayAlerts(Boolean RHS). i.e When calling
ExcelApp.DisplayAlerts = false;
.

Office version: Office 365 v16.0.11328.20420 64-bit in windows 10 64-bit.

I need to turn-off Display Alerts as I need to over write the existing file for csv due to original issue.

1. One thing I noticed is for Office 365, the issue happens only after opening csv file, type some text and leave the cursor in the cell, and click "save" icon from Ribbon commands.

2. for Office 2010 64-bit, even I clicked some where else also, I am getting same COM Exception.

Is there any way to fix the issue?

Thanks,
Lakshman.
Posted 08 Oct, 2019 04:16:07 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Lakshman,

I suggest that you set the Thread.CurrentThread.CurrentCulture as we do this at https://www.add-in-express.com/creating-addins-blog/2009/02/13/old-format-invalid-type-library/.


Andrei Smolin
Add-in Express Team Leader
Posted 08 Oct, 2019 06:43:52 Top
Lakshman Kumar


Guest


Hi,

Thanks for the reply.

I tried the above suggestion, but still getting the same exception. Could you please suggest any other ways to fix the issue?

Thanks,
Lakshman.
Posted 08 Oct, 2019 21:27:31 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Lakshman,

How can I reproduce the issue? Do you have some code and steps to follow?


Andrei Smolin
Add-in Express Team Leader
Posted 09 Oct, 2019 03:13:32 Top
Lakshman Kumar


Guest


Hi,

Thanks for the reply.

Please find the sample excel add-in in the following path.

https://drive.google.com/open?id=1Zj9qStBhgIrAVnLX-RT0CAzRndaTQmfO

Steps to reproduce:
1. open existing csv file, type few characters and let the cursor be there in the cell itself. (don't press ENTER/TAB etc..).
2. click on "save" icon button from ribbon. (overriden ribben save command)
3. will be notified with exception. (message box).

Please let me know if need more details.

Thanks,
Posted 09 Oct, 2019 04:03:12 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Lakshman,

I'm sorry for missing this description earlier. The exception occurs because you cannot call save while the user edits a cell. On how to detect this scenario, see https://www.add-in-express.com/creating-addins-blog/2011/03/23/excel-check-user-edit-cell/.


Andrei Smolin
Add-in Express Team Leader
Posted 09 Oct, 2019 04:07:16 Top
Lakshman Kumar


Guest


Hi,

Thanks for the reply. I'll look at the posted URL.

But why this is happening only when I override the save ribbon command with same test?

First I had only BeforeSave event, then I didn't get the exception, but once I started overriding save ribbon command issue starts happening.


Thanks,
Posted 09 Oct, 2019 04:28:37 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Lakshman,

I suppose this occurs because there are several phases after you click the button Save; the Ribbon command is invoked on an early phase (to let you cancel the click).

I assume that after the command's event is processed (the click is not cancelled), Excel finds out that the user edits a cell, cancels the edit (most probably, it saves the currently edited value to the cell) and starts saving the document; this is the moment when you receive the WorkbookBeforeSave event.


Andrei Smolin
Add-in Express Team Leader
Posted 09 Oct, 2019 06:04:01 Top