在 Excel 2010 中使用 VBA 代码调用 Web 服务

发布于 2024-09-14 17:30:34 字数 78 浏览 2 评论 0原文

我正在尝试在 Excel 2010 中编写一些使用 Web 服务的 VBA 代码。我无法在互联网上找到任何相关资源。有人可以告诉我该怎么做吗?

I am trying to write some VBA code in Excel 2010 that would consume a web service. I am unable to find any related resources on the internet. Can someone please tell me how to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

小矜持 2024-09-21 17:30:34

我在最近的一个项目中遇到了同样的问题,我想在纯 VBA 中与 Trello 和 Salesforce 对话,而不需要安装任何插件、打开 Visual Studio 或其他 hack。最终编写了我自己的库(很大程度上基于我最喜欢的库之一,RestSharp)。

警告,无耻插件: https://github.com/VBA-tools/VBA-Web

一些有趣的功能包括Mac 支持(!)、身份验证(Http Basic、OAuth1、OAuth2 等)、异步支持和 JSON 解析(感谢 VBA-JSON

它在 Excel 2010 和 2013(很可能是 2007)中运行得非常好,我已经让它与 Salesforce、Trello、Basecamp、Google 地图一起工作,并且它应该与几乎任何网络服务一起工作。

I struggled with the same question on a recent project of mine where I wanted to talk to Trello and Salesforce in pure VBA without installing any plugins, opening up Visual Studio, or other hacks. Ended up writing my own library (based heavily on one of my favorites, RestSharp).

Warning, shameless plug: https://github.com/VBA-tools/VBA-Web

Some fun features include Mac support(!), authentication (Http Basic, OAuth1, OAuth2, and others), Async support, and JSON parsing (thanks to VBA-JSON)

It's working awesomely in Excel 2010 and 2013 (and most likely 2007) and I've got it working with Salesforce, Trello, Basecamp, Google Maps, and it should work with pretty much any webservice.

小清晰的声音 2024-09-21 17:30:34

我不认为标记为答案的帖子是正确的 - 它链接到 Excel 2003 解决方案,该解决方案基于 MS Office Web Services Toolkit。该解决方案不再有效,因为不再支持该工具包。请参阅:MSDN - 在 Excel 2007 中使用 Web 服务。该链接提供了适用于 Excel 2007 的解决方案,该解决方案可以转换为 Excel 2010。不过,您将需要带有 Microsoft Office 开发人员工具的 Visual Studio 2010。它还意味着利用 .Net Framework 并使用 C# 或 VB.NET 进行编码。

I don't think the post marked as the answer is right - it links to the Excel 2003 solution, which was based on the MS Office Web Services Toolkit. That solution is no longer valid as the Toolkit is not supported any more. See: MSDN - Consuming Web Services in Excel 2007. The link provides a solution for Excel 2007 which can be transposed to Excel 2010. You will need Visual Studio 2010 with Microsoft Office Developers Tools though. It also means utilising .Net Framework and coding in C# or VB.NET.

零時差 2024-09-21 17:30:34

FWIW 截至发帖时,我发现 Excel 2003 的旧 Web 引用工具包仍然可以在 Excel 2007/10 中生成工作 VBA 代码(请注意,在过去 18 个月中,各种 Windows 更新出现了一些不稳定的时刻,停止此代码工作,所以我不会认为我的解决方案“可靠”)。

我可怕的 hack 涉及安装 Excel 2003,然后安装 Web References Toolkit,然后安装 Excel 2007 或 Excel 2010。我已经使用此 hack 设置了 3 台 PC,并且所有 PC 都生成工作 VBA 代码来使用 asmx Web 服务(我还没有尝试过)与其他类型的网络服务连接,但我不明白为什么它们不起作用)。

使用 VSTO 的官方 MS 方法对于我们的一些客户来说太过分了,而这个 VBA 黑客让他们很高兴。

FWIW as of the time of posting I've found that the old Web References Toolkit of Excel 2003 still produces working VBA code in Excel 2007/10 (note that there have been some shaky moments with various Windows updates over the last 18 months that has stopped this code working so I wouldn't consider my solution 'reliable').

My horrible hack involves installing Excel 2003, then the Web References Toolkit, then installing Excel 2007 or Excel 2010. I've set up 3 PCs using this hack and all are producing working VBA code to consume asmx web services (I haven't tried connecting with other types of web service but I don't see why they wouldn't work).

The official MS method, using VSTO, is a step too far for some of our clients and this VBA hack has kept them happy.

月依秋水 2024-09-21 17:30:34

Windows Communication Foundation (WCF) 服务名称,用于将 Web 服务集成到基于 COM 的开发环境中,例如 Microsoft Office Visual Basic for Applications (Office VBA) 或 Visual Basic 6.0。
有关详细信息,请参阅链接 https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/using-the-wcf-moniker-with-com-clients

Windows Communication Foundation (WCF) service moniker to integrate Web services into COM-based development environments, such as Microsoft Office Visual Basic for Applications (Office VBA) or Visual Basic 6.0.
For detail see link https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/using-the-wcf-moniker-with-com-clients

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文