PC Review


Reply
Thread Tools Rate Thread

code to add control to a worksheet

 
 
mark kubicki
Guest
Posts: n/a
 
      4th Dec 2006
I know that:
Set Mycmd = Controls.Add("MSForms.CommandButton.1") ', CommandButton2,
Visible)
will add a control to a form

what would the code be to add a control to a worksheet? (are there any
tricks I will need to do to make it functional (de-activate / activate
worksheet...))

thanks in advance
mark


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9obiBCdW5keQ==?=
Guest
Posts: n/a
 
      4th Dec 2006
When in doubt, record a macro that does what your trying to accomplish, then
edit the code to suit your needs, great way to learn and help you remember
long forgotten functionality. This is what recorded when I added a button.
Can't get much better.

ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=79.5, Top:=135.75, Width:=64.5, Height _
:=25.5).Select

-John


"mark kubicki" wrote:

> I know that:
> Set Mycmd = Controls.Add("MSForms.CommandButton.1") ', CommandButton2,
> Visible)
> will add a control to a form
>
> what would the code be to add a control to a worksheet? (are there any
> tricks I will need to do to make it functional (de-activate / activate
> worksheet...))
>
> thanks in advance
> mark
>
>
>

 
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
Code "crashes" after dynamically adding control to worksheet --elizabeth Microsoft Excel Programming 3 27th May 2010 09:25 PM
c# code to add button control to the worksheet!!!! .NetProf Microsoft Excel Programming 0 30th Jan 2006 04:45 AM
Reference to ActiveX control on worksheet requires full worksheet name Ian Ripsher Microsoft Excel Programming 3 25th Jun 2005 04:22 PM
Design Best Practices: Form Control Code in Worksheet or Module =?Utf-8?B?QmluZw==?= Microsoft Excel Programming 2 23rd Dec 2004 02:31 PM
Worksheet.Calculate code no longer executes on worksheet launch? Arris Microsoft Excel Worksheet Functions 1 28th Jan 2004 02:17 PM


Features
 

Advertising
 

Newsgroups
 


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