vba Excel 2010 中的“表单控件”和“ActiveX 控件”有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15455179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 15:09:41  来源:igfitidea点击:

What is the difference between "Form Controls" and "ActiveX Control" in Excel 2010?

excelvbaexcel-2010activexform-control

提问by Rubens Mariuzzo

Using Microsoft Excel 2010, I noticed two kind of controls that can be inserted into a document: Form Controlsand ActiveX Controls.

使用 Microsoft Excel 2010,我注意到可以插入到文档中的两种控件:表单控件ActiveX 控件

enter image description here

在此处输入图片说明

What is the difference between them?

它们之间有什么区别?

采纳答案by StoriKnow

Google is full of information on this. As Hans Passant said, Form controlsare built in to Excel whereas ActiveXcontrols are loaded separately.

谷歌上有很多这方面的信息。正如 Hans Passant 所说,表单控件内置于 Excel 中,而ActiveX控件是单独加载的。

Generally you'll use Formscontrols, they're simpler. ActiveXcontrols allow for more flexible design and should be used when the job just can't be done with a basic Formscontrol.

通常您会使用Forms控件,它们更简单。ActiveX控件允许更灵活的设计,应该在基本Forms控件无法完成工作时使用。

Many user's computers by default won't trustActiveX, and it will be disabled; this sometimes needs to be manually added to the trust center. ActiveXis 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.

很多用户的电脑默认是不信任的ActiveX,会被禁用;这有时需要手动添加到信任中心。ActiveX是一种基于微软的技术,据我所知,在 Mac 上不受支持。如果您(或您提供工作簿的任何人)决定在 Mac 上使用它,您还必须考虑这一点。

回答by iliketocode

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 控件显示为您可以在代码中使用的对象 - 尝试将 ActiveX 控件插入工作表,调出 VBA 编辑器 (ALT + F11),您将能够访问以编程方式控制。你不能用表单控件来做到这一点(宏必须显式分配给每个控件),但表单控件更容易使用。如果您只是在做一些简单的事情,那么使用哪个并不重要,但是对于更高级的脚本,ActiveX 具有更好的可能性。

ActiveX is also more customizable.

ActiveX 也更具可定制性。

回答by JLG

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.

请注意,在某些情况下,单击表单控件或 Active X 控件会为同一个宏提供两种不同的结果 - 这不应该是这种情况。我发现 Active X 更可靠。

回答by maciej

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.

还值得注意的是,ActiveX 控件仅适用于 Windows,而 Form Controls 将适用于 Windows 和 MacOS 版本的 Excel。