code to add control to a worksheet

  • Thread starter Thread starter mark kubicki
  • Start date Start date
M

mark kubicki

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
 
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
 

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

Back
Top