Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling web service using VBA code in Excel 2010

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.

like image 222
Aadith Ramia Avatar asked Aug 19 '10 12:08

Aadith Ramia


People also ask

Can Excel call a Web service?

EXCEL and the Web Services Toolkit After the installation, the Web Services plug-in can be found in the Excel VB editor under Extras > Web Service References. Excel is now ready to import WSDL files for the automatic creation of classes and data types to call the corresponding web services.

Can you use VBA in Excel for the Web?

Although you can't create, run, or edit VBA (Visual Basic for Applications) macros in Excel for the web, you can open and edit a workbook that contains macros. Any existing macros will remain in the workbook, and you can open the workbook in the Excel desktop app to view and edit the macros.

How do I use VBA in Excel 2010?

Select the Developer tab from the toolbar at the top of the screen. Then click on the Visual Basic option in the Code group. Now the Microsoft Visual Basic editor should appear and you can view your VBA code.


2 Answers

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.

like image 80
Tim Hall Avatar answered Sep 27 '22 20:09

Tim Hall


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.

like image 27
Juliusz Avatar answered Sep 27 '22 21:09

Juliusz