使用 Windows Socket 和 Excel VBA 的轻客户端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4803329/
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
Light Client using Windows Socket and Excel VBA
提问by BlackLabrador
I have an excel workbook containing a lot of different data. On the other side, I have a server in Java that does a lot of computing work. I would need to connect my XL Workbook this server using a TCP protocol and send data from Excel to Java
我有一个包含许多不同数据的 Excel 工作簿。另一方面,我有一个用 Java 编写的服务器,它执行大量计算工作。我需要使用 TCP 协议将此服务器连接到我的 XL Workbook 并将数据从 Excel 发送到 Java
What is the easiest way to do that ? I've heard that winsocks control can be used with VBA. Where can I download the library to do that (is there an official MS library ? => a lot of guy are talking of MSWINSCK.OCX, but I can't find that anywhere on the microsoft website).
最简单的方法是什么?我听说 winsocks 控件可以与 VBA 一起使用。我在哪里可以下载库来做到这一点(是否有官方的 MS 库?=> 很多人都在谈论 MSWINSCK.OCX,但我在微软网站上的任何地方都找不到)。
Would you have an example or a link in VBA for a small project able to send data and receive data from a server ?
对于一个能够从服务器发送数据和接收数据的小项目,您是否有 VBA 中的示例或链接?
Thanks Rgds
感谢 Rgds
回答by mupan
mswinsck.ocx is part of VB runtimes (e.g. http://support.microsoft.com/kb/932349). The same link informs about security issues possibly related to mswinsck.ocx. When you will have downloaded the most recent and hopefully most secure version of the ocx (or found it on your hard disk because you have runtime of vb installed, you might have to register it manually by regsvr32 on the Windows console. On Windows 7, you even might have to activate it additionally e.g. with this tool: http://www.nirsoft.net/utils/acm.html.
mswinsck.ocx 是 VB 运行时的一部分(例如http://support.microsoft.com/kb/932349)。同一链接告知可能与 mswinsck.ocx 相关的安全问题。当您下载了最新且希望是最安全的 ocx 版本(或在您的硬盘上找到了它,因为您安装了 vb 运行时,您可能需要在 Windows 控制台上通过 regsvr32 手动注册它。在 Windows 7 上,您甚至可能需要另外激活它,例如使用此工具:http: //www.nirsoft.net/utils/acm.html。
If all this is done, add a reference to your VBA project to Microsoft Winsock Control v.... (SP ...).If you prefer late binding for this, you can remove the ref later, but now it's necessary to have MSWinsocketLibavailable in the Object Catalogue (<F2>) in your VBA project and for IntelliSense while coding.
如果所有这些都完成了,请将您的 VBA 项目的引用添加到Microsoft Winsock Control v.... (SP ...)。如果您更喜欢后期绑定,您可以稍后删除 ref,但现在必须在 VBA 项目的对象目录 (<F2>) 中提供MSWinsocketLib,并在编码时用于 IntelliSense。
I found out what I am telling you by searching the internet for mswinsck.ocx site:microsoft.com, and, after a short look into the Object Catalogue, searching for a most specific expression, found: http://www.15seconds.com/issue/010820.htmwhere is basic information and links to further articles.
我通过在 Internet 上搜索 mswinsck.ocx 站点:microsoft.com 找到了我要告诉您的内容,并在对对象目录进行了简短查看后,搜索了最具体的表达式,找到了:http://www.15seconds。 com/issue/010820.htm基本信息和进一步文章的链接在哪里。
But:It seems to me Winsocket is a rather old technique. The article on 15seconds is from 2001 I guess. I won't dig further because we early ref winsck.ocx and thus force admins to install our software to regsvr32 mswinsck.ocx for a reason I don't wanna know. Maybe just to let admins know how ripe our software is ... On the pages the search engines found alternatives like csocket (API) are mentioned, so please dig further.
但是:在我看来,Winsocket 是一种相当古老的技术。关于 15seconds 的文章我猜是 2001 年的。我不会进一步挖掘,因为我们很早就引用了 winsck.ocx,因此出于我不想知道的原因,因此强制管理员将我们的软件安装到 regsvr32 mswinsck.ocx。也许只是为了让管理员知道我们的软件有多成熟......在搜索引擎找到的替代品的页面上,如 csocket (API) 被提及,所以请进一步挖掘。
Since this is no solution but just hints and discussion I would have preferred to just comment your question, but there is no link for me to add a comment, I might lack a funny stackoverflow right.
由于这不是解决方案,而只是提示和讨论,我宁愿只评论您的问题,但没有链接供我添加评论,我可能缺乏有趣的计算器溢出权利。