A doubt on worksheet.CustomProperties...

N

NA_AB

hi all, please help me with this. This is so very annoying and am not able to
solve :(

I am getting an error while trying to add a name-value pair to the excel
sheet's custom properties. The exception says: Exception from HRESULT:
0x800A03EC
I tried googling about this but to no use.

The surprising element is,

MySheet.CustomProperties.Add(Name,Value); //Name--string, Value-- any object

When the object is a simple object which has some ints, doubles, strings etc
such basic data types, it is working fine. How ever in my application, I want
to add 'sample' class' objects to the sheet's custom properties.

The 'sample' class is as shown:

class sample
{
OLEObject o;
Shape btn;
private Worksheet sht;
MSForms.CommandButton mbtn_1;
private static object Opt = Type.Missing;
Range act;
public string name;

public sample(string s)
{
name = s;
sht = (Worksheet)Connect.MyApplication.ActiveSheet;
act = Connect.MyApplication.ActiveCell;
btn = sht.Shapes.AddOLEObject("Forms.CommandButton.1",
Opt, Opt, Opt, Opt, Opt, Opt,
sht.get_Range(act, act).Left,
sht.get_Range(act, act).Top,
sht.get_Range(act, act).Width,
((double)sht.get_Range(act, act).
Height) * 2);
o = (OLEObject)btn.DrawingObject;
mbtn_1 = (MSForms.CommandButton)(o_Object);
mbtn_1.Caption = "search";
mbtn_1.Click += new
MSForms.CommandButtonEvents_ClickEventHandler(search_me);
}
public void search_me()
{
act.Cells[1, 2] = name;
}
}


When am trying to add a custom property with a value as an object of sample
class, I am getting this exception(Exception from HRESULT: 0x800A03EC ). Can
anyone here tell me where the mistake lies?! Or is it allowed in the first
place to add any object that contains things like MSForms.CommandButton etc!?
because, it gives me no exception if am trying to add an object with basic
datatypes such as ints and strings.

Thanks in advance.

Regards.
 

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