Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

Created Unassigned: Access to COM Object when VBA editor is opened throw exception [21823]

$
0
0
Hi,
I had made an excel addIn with netOffice, I found the following issue.

Issue:
Access to COM Object when VBA editor is opened throw exception.

How to replicate:
1. Use the attached project (IExtensibility COMAddin Examples), an addin based on your example with only one change in the OnAction Method (see below the code in OnAction Method).

2. Open Excel (I use office 2013)

3. Click on Button1 on the AddIn's tab in the ribbon --> all works correctly

4. Open the VBA editor:
* Click on Developer Tab in the ribbon (to enable this tab in excel option -> Customize Ribbon -> Check Developer checkbox on the right side)
* Click on Visual Basic button
* Click on View -> Code
* Write anything in the code window

5. Don't close the VBA editor and reClick on Button1 on the AddIn's tab in the ribbon --> this time an exception occured (see below exception message)

My code in OnAction Method:
```
foreach (Excel.Workbook wb in _excelApplication.Workbooks)
{
Excel.Sheets wss = wb.Worksheets;
foreach (Excel.Worksheet ws in wss)
{
MessageBox.Show("Name: " + ws.Name);
}
}

```
Exception:
```
System.Runtime.InteropServices.COMException was unhandled by user code
HResult=-2147467259
Message=See inner exception(s) for details.
Source=NetOffice
ErrorCode=-2147467259

Exception StackTrace:
at NetOffice.Invoker.PropertyGet(COMObject comObject, String name, Object[] paramsArray)
at NetOffice.ExcelApi._Worksheet.get_Name()
at COMAddinRibbonExampleCS45.Addin.OnAction(IRibbonControl control) in c:\Users\LucaGaggero\Desktop\IExtensibility COMAddin Examples\RibbonUI\Addin.cs:line 101

Inner Exception:
System.Runtime.InteropServices.COMException (0x800A9C64): Exception from HRESULT: 0x800A9C64
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at NetOffice.Invoker.PropertyGet(COMObject comObject, String name, Object[] paramsArray)

```

Have you any idea to fix this bug?

Thanks for your help,
regards

Luca

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>