问题
Using Microsoft Excel 2010, I noticed two kind of controls that can be inserted into a document: Form Controls and ActiveX Controls.
What is the difference between them?
回答1:
Google is full of information on this. As Hans Passant said, Form controls are built in to Excel whereas ActiveX controls are loaded separately.
Generally you'll use Forms
controls, they're simpler. ActiveX
controls allow for more flexible design and should be used when the job just can't be done with a basic Forms
control.
Many user's computers by default won't trust ActiveX
, and it will be disabled; this sometimes needs to be manually added to the trust center. ActiveX
is a microsoft-based technology and, as far as I'm aware, is not supported on the Mac. This is something you'll have to also consider, should you (or anyone you provide a workbook to) decide to use it on a Mac.
回答2:
One major difference that is important to know is that ActiveX controls show up as objects that you can use in your code- try inserting an ActiveX control into a worksheet, bring up the VBA editor (ALT + F11) and you will be able to access the control programatically. You can't do this with form controls (macros must instead be explicitly assigned to each control), but form controls are a little easier to use. If you are just doing something simple, it doesn't matter which you use but for more advanced scripts ActiveX has better possibilities.
ActiveX is also more customizable.
回答3:
Be careful, in some cases clicking on a Form Control or Active X Control will give two different results for the same macro - which should not be the case. I find Active X more reliable.
回答4:
It's also worth noting that ActiveX controls only work in Windows, whereas Form Controls will work on both Windows and MacOS versions of Excel.
来源:https://stackoverflow.com/questions/15455179/what-is-the-difference-between-form-controls-and-activex-control-in-excel-20