Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default to add a button to the active excel cell! here's the way!

hey ppl n hi peter! at last, found a way out.

Range r = Connect.myApplication.ActiveCell;
Microsoft.Office.Interop.Excel.Worksheet theSheet =
(Microsoft.Office.Interop.Excel.Worksheet)Connect. myApplication.Worksheets.get_Item(1);
theSheet.Shapes.AddOLEObject("Forms.CommandButton. 1",
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
"click_me", theSheet.get_Range(r, r).Left,theSheet.get_Range(r,
r).Top, theSheet.get_Range(r,
r).Width, theSheet.get_Range(r, r).Height);


Requires you to add MSForms 2.0, your addin should have a reference to
MSForms object library and use as MSForms.CommandButton.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default to add a button to the active excel cell! here's the way!

but hey, how to handle this button's click!? anybody help!!!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default to add a button to the active excel cell! here's the way!

Hello again,

As I tried to explain in my first reply in your thread "a button on an excel
cell" on 6-Jan, you do this in almost the same was as you handle the click
event of an Office.CommandBarButton. I think you already know how to do that
in C#, as you know I don't, but the main difference will be to declare as
MSForms.CommandButton.

Rather than starting a new thread try its better for all if you post
follow-ups in the original thread.

Regards,
Peter T

"NA_AB" wrote in message
...
but hey, how to handle this button's click!? anybody help!!!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default to add a button to the active excel cell! here's the way!

On 9 Jan, 19:27, "Peter T" <peter_t@discussions wrote:
Hello again,

As I tried to explain in my first reply in your thread "a button on an excel
cell" on 6-Jan, you do this in almost the same was as you handle the click
event of an Office.CommandBarButton. I think you already know how to do that
in C#, as you know I don't, but the main difference will be to declare as
MSForms.CommandButton.

Rather than starting a new thread try its better for all if you post
follow-ups in the original thread.

Regards,
Peter T

"NA_AB" wrote in message

...

but hey, how to handle this button's click!? anybody help!!!


hey dude, cud find a way out atlast: :)

Range r = Connect.myApplication.ActiveCell;
Worksheet sht = (Worksheet)
Connect.myApplication.ActiveSheet;
Shape btn = sht.Shapes.AddOLEObject("Forms.CommandButton.
1", Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
sht.get_Range(r,
r).Left, sht.get_Range(r, r).Top, 60,20);//sht.get_Range(r,r).Width,
sht.get_Range(r, r).Height);
OLEObject obj1 = (OLEObject)(sht.OLEObjects
("CommandButton1"));
MSForms.CommandButton mbtn = (MSForms.CommandButton)
(obj1.Object);
mbtn.Caption = "click me";
mbtn.Click += new
Microsoft.Vbe.Interop.Forms.CommandButtonEvents_Cl ickEventHandler
(main_form_click);
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
XL2002 - Cell Reference for Active Button Trevor Williams Excel Programming 4 May 10th 07 01:41 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
Adding a control button to insert a date in the active cell. Mike Excel Discussion (Misc queries) 2 February 15th 05 06:27 PM
Change active cell properties with command button Nick Excel Programming 2 January 30th 04 05:11 PM
Change active cell properties with command button Beto[_3_] Excel Programming 0 January 30th 04 04:58 PM


All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"