VBA code for controls on Microsoft Form 2.0

MichaelSchulz

Board Regular
Joined
Apr 10, 2014
Messages
64
I know how to code for controls placed on a sheet, both form controls and ActiveX.

And I know how to create and code for a UserForm.

But here is where I am having a problem:

I have inserted a Microsoft Form 2.0 onto an Excel Sheet. On that form, I have placed a Command Button.
I cannot find how to code for the click event of that button. The same is true for any other controls placed on the form.

I can view code for the form and write code for that, e.g. clicking on the form itself.

But when I try to view code for any control on the form, that option is greyed out.

What do I need to do for my code to reach the controls on a Form 2.0?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
On the Developer Tab, in the Controls section, click the Insert button.

In the ActiveX options, click the More Controls icon (bottom-right).

In the More Controls dialog box, select Microsoft Forms 2.0 Frame and click OK.

On the Sheet, click-and-drag a rectangle for the form frame.

Right-click on the frame and select Frame Object » Edit.

The Toolbox should appear; if it does not, right-click on the frame again and select Toolbox…

From the Toolbox, click a control and add it to the frame.

If you want to edit the control properties, right-click on object and select Properties…

In that same menu, I see an option to View Code… but it is greyed out.
 
Upvote 0
I'll have to pass on that question. That said, ActiveX controls can be unreliable when placed on a worksheet. They are really designed for UserForms.
 
Upvote 0
Frames (MSForms 2.0) are a way to group controls into a replicable control-set, similar in some aspects to Userforms. The main functional difference is that frames are just another (container) control that you can embed directly in the worksheet whereas Userforms must be explicitly displayed by VBA code.
BEWARE: my past experience experimenting with Frames, and MSForms 2.0 generally, is that they are very buggy! Microsoft seems to have abandoned them to the wilderness of bug-laden functionality that no one uses because the bug-workaround effort isn't worth their extra, otherwise useful functionality. Past testing also suggests that they are a big memory hog.
 
Upvote 0

Forum statistics

Threads
1,216,072
Messages
6,128,632
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top