VBA 中的 MS 通信控制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13506611/
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
MS Comm Control in VBA
提问by Jay
I am using VBA for Excel. My requirement is that the forms created in VBA shall communicate with external system over serial port of my system. For the same purpose, like we do in VB, I am tring to add MS Comm Control in VBA.
我正在为 Excel 使用 VBA。我的要求是在 VBA 中创建的表单应通过我系统的串行端口与外部系统通信。出于同样的目的,就像我们在 VB 中所做的那样,我想在 VBA 中添加 MS Comm Control。
I am able to add MS Comm Control to control panel by selecting the same from Tools -> Additional Controls
. However, when I try to place MSComm
control on my form, it gives me following error.
我可以通过从Tools -> Additional Controls
. 但是,当我尝试MSComm
在表单上放置控件时,它给了我以下错误。
The subject is not trusted for specified action.
对于指定的操作,主体不受信任。
Due to this, I am not able to place the control on my form and hence not able to use the same.
因此,我无法将控件放在我的表单上,因此无法使用它。
The same behaviour is observed for MS Winsock
Control.
对于 MSWinsock
控制观察到相同的行为。
Found a similar question on stackoverflow: MSCOMM32.ocx usage causes Not Trusted Errorwithout any concrete answer.
在 stackoverflow 上发现了一个类似的问题:MSCOMM32.ocx 使用导致 Not Trusted Error没有任何具体答案。
My installations are: Win XP - SP3, MS Office 2010, VB6, MS VS 2010.
我的安装是:Win XP - SP3、MS Office 2010、VB6、MS VS 2010。
回答by Bob77
Legal use of VB6 controls in an Excel macro (or in any 3rd party program or programming language) is restricted. The only exceptions are when you have licensed Office Developer Edition (or in newer versions of Office the extra developer package that contains VSTO or equivalent) or if you are just creating them for use on the same machine that has VB6 installed.
在 Excel 宏(或任何第三方程序或编程语言)中合法使用 VB6 控件受到限制。唯一的例外是当您已获得 Office Developer Edition 的许可(或在较新版本的 Office 中包含包含 VSTO 或等效物的额外开发人员包),或者您只是创建它们以在安装了 VB6 的同一台计算机上使用时。
But your problem is probably either related to Microsoft kill-bitting the OCX (which prevents use in IE, and maybe in Office?), or more likely that you are using 64-bit Excel (and thus 64-bit VBA).
但是您的问题可能与 Microsoft 对 OCX 的攻击有关(这会阻止在 IE 中使用,也可能与在 Office 中使用?)有关,或者更有可能与您使用的是 64 位 Excel(以及 64 位 VBA)有关。
回答by Bunphot Kliaphuangphit
I got similar problem but with MsWinSck.OCX. I fixed it by loading ActiveX Compatibility Manager from http://www.nirsoft.net/utils/acm.htmland enable the OCX (Winsck.OCX) by selecting the OCX in the lines then click the green LED on the menu.
我遇到了类似的问题,但使用 MsWinSck.OCX。我通过从http://www.nirsoft.net/utils/acm.html加载 ActiveX 兼容性管理器来修复它,并通过在行中选择 OCX 来启用 OCX (Winsck.OCX),然后单击菜单上的绿色 LED。
Hope this may help.
希望这可能会有所帮助。