PC Review


Reply
Thread Tools Rate Thread

Add button to worksheet cell

 
 
=?Utf-8?B?Q3J1c2FkZXI=?=
Guest
Posts: n/a
 
      23rd Nov 2006
Hi,

I am able to add a button in an excel worksheet cell in C# code. Now I want
to handle its click event in the C# itself.

Here is the code I have tried:

Excel.Buttons buttons = activeSheet.Buttons(System.Reflection.Missing.Value)
as Excel.Buttons;
Excel.Button button = null;
button = buttons.Add(5, 5, 100, 20);
button.Caption = "Trend Chart";

Now, there is one property of button class named ".OnAction". I guess we can
only define the macro name in this.
Kindly let me know how to handle its click event in C# instead of calling
macro?

Thanks,
Sunil

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TXIuRw==?=
Guest
Posts: n/a
 
      23rd Nov 2006
I hope I understand correctly.
If you go into design mode and you double click the button.It will give you
a on click event. Then add code.
G

"Crusader" wrote:

> Hi,
>
> I am able to add a button in an excel worksheet cell in C# code. Now I want
> to handle its click event in the C# itself.
>
> Here is the code I have tried:
>
> Excel.Buttons buttons = activeSheet.Buttons(System.Reflection.Missing.Value)
> as Excel.Buttons;
> Excel.Button button = null;
> button = buttons.Add(5, 5, 100, 20);
> button.Caption = "Trend Chart";
>
> Now, there is one property of button class named ".OnAction". I guess we can
> only define the macro name in this.
> Kindly let me know how to handle its click event in C# instead of calling
> macro?
>
> Thanks,
> Sunil
>

 
Reply With Quote
 
=?Utf-8?B?Q3J1c2FkZXI=?=
Guest
Posts: n/a
 
      23rd Nov 2006
Hi,

We are adding button programmatically to the Excel Worksheet. So, button
will be available only at run time. There is no such option to double click
it and write desired code for the click action.

Thanks,
Crusader

"Mr.G" wrote:

> I hope I understand correctly.
> If you go into design mode and you double click the button.It will give you
> a on click event. Then add code.
> G
>
> "Crusader" wrote:
>
> > Hi,
> >
> > I am able to add a button in an excel worksheet cell in C# code. Now I want
> > to handle its click event in the C# itself.
> >
> > Here is the code I have tried:
> >
> > Excel.Buttons buttons = activeSheet.Buttons(System.Reflection.Missing.Value)
> > as Excel.Buttons;
> > Excel.Button button = null;
> > button = buttons.Add(5, 5, 100, 20);
> > button.Caption = "Trend Chart";
> >
> > Now, there is one property of button class named ".OnAction". I guess we can
> > only define the macro name in this.
> > Kindly let me know how to handle its click event in C# instead of calling
> > macro?
> >
> > Thanks,
> > Sunil
> >

 
Reply With Quote
 
Waseem Chishti
Guest
Posts: n/a
 
      21st Dec 2006
HI Crusader;

I am currently facing the same problem. I managed to add buttons in
excel worksheet programmatically, but could not set what method to call
on OnAction. I would highly appreciate if you share the solution with
me if you found one. I searched the net but was unable to find a
solution.

Waseem


Crusader wrote:
> Hi,
>
> We are adding button programmatically to the Excel Worksheet. So, button
> will be available only at run time. There is no such option to double click
> it and write desired code for the click action.
>
> Thanks,
> Crusader
>
> "Mr.G" wrote:
>
> > I hope I understand correctly.
> > If you go into design mode and you double click the button.It will give you
> > a on click event. Then add code.
> > G
> >
> > "Crusader" wrote:
> >
> > > Hi,
> > >
> > > I am able to add a button in an excel worksheet cell in C# code. Now I want
> > > to handle its click event in the C# itself.
> > >
> > > Here is the code I have tried:
> > >
> > > Excel.Buttons buttons = activeSheet.Buttons(System.Reflection.Missing.Value)
> > > as Excel.Buttons;
> > > Excel.Button button = null;
> > > button = buttons.Add(5, 5, 100, 20);
> > > button.Caption = "Trend Chart";
> > >
> > > Now, there is one property of button class named ".OnAction". I guess we can
> > > only define the macro name in this.
> > > Kindly let me know how to handle its click event in C# instead of calling
> > > macro?
> > >
> > > Thanks,
> > > Sunil
> > >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Worksheet Button Caption on Worksheet.Activate =?Utf-8?B?TWlrZVp6?= Microsoft Excel Programming 1 7th Dec 2006 06:01 AM
Problem: vba code for creating a button to save worksheet as Cell =?Utf-8?B?Y2FsZG9n?= Microsoft Excel Programming 7 26th Sep 2006 10:04 PM
Place The Contents Of A Cell From The Active Worksheet Into A Cell On An Inavtive Worksheet Minitman Microsoft Excel Programming 1 25th Feb 2004 04:26 AM
Place The Contents Of A Cell From The Active Worksheet Into A Cell On An Inavtive Worksheet Minitman Microsoft Excel Worksheet Functions 1 25th Feb 2004 04:26 AM
Place The Contents Of A Cell From The Active Worksheet Into A Cell On An Inavtive Worksheet Minitman Microsoft Excel Misc 1 25th Feb 2004 04:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:31 PM.