19

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.

7
  • Jimmy Peña's blog has an excellent series of articles on doing just that. codeforexcelandoutlook.com/blog/category/internet-explorer Commented Aug 19, 2010 at 13:22
  • unfortunately there was nothing related to this particular problem in this site Commented Aug 20, 2010 at 4:41
  • Search for web services on his blog, you should find something. codeforexcelandoutlook.com/blog/2010/06/… Commented Aug 21, 2010 at 0:09
  • You might find this useful. It should apply equally well to Excel 2010. Found this too. Commented Mar 9, 2011 at 10:24
  • 1
    This is an old question but... I've just discovered the '=WEBSERVICE' function in Excel 2013. Simple as can be... see blogs.office.com/2013/03/21/… Commented Mar 11, 2015 at 19:53

4 Answers 4

38

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow. Great piece of work, have not tested it yet, but looks awesome. Thanks a lot!
7

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.

7 Comments

-1, the question asked for VBA. This reply requires Visual Studio.
Fair enough. In my opinion MS would like to have VBA dead and it is pushing .net solutions for Office. On the seperate note, you don't have to use Visual Studio. You can use NotePad and command line compiler.
One would be surprised about the number of banks (even very large) that would nearly stop working if VBA disappeared tomorrow !!!
Funny, I am working for one of those and they would be very happy with removing any code from an Excel binary file. Some of them have even done that; they have VBA modules stored in a code repository and a workbook is rebuilt from those for each release.
My point is that MS actively discourage VBA coding and try to shift development to .net and Visual Studio. The removal of MS Office Web Services Toolkit is an example. So VBA will not disappear tomorrow, but its days are numbered. Like it or not.
|
3

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.