Click here to Skip to main content
Licence 
First Posted 31 Aug 2003
Views 104,046
Bookmarked 40 times

Consuming Web Services from MS Excel

By | 31 Aug 2003 | Article
How to access a web service from Microsoft Excel

Introduction

Web Services are reusable applications that expose an interface that can be accessed over the internet. Web services use XML to provide a platform and language independent implementation of distributed application services and information.

Web services allow us to utilize the services provided by the other organizations. We can consume the web services not only from applications developed using various programming languages but also from Microsoft office tools like Access, Excel, and Word etc. In this article we will explore how we can access a web service from Microsoft Excel using Microsoft Office XP Web Services Toolkit 2.0, which simplifies the process of accessing and utilizing an XML webservice.

Details

 Sample screenshot

The example includes a webservice, which returns 5 countries and their capitals. Capitals.xls has 2 buttons. When a user clicks on the display button, Capitals.xls sheet accesses the web service and displays the data provided by the webservice. Clicking on the clear button clears the data from the XL sheet.

Sample screenshot

Now lets see how we can develop this application. Lets start by creating an excel sheet. Drag and drop a button from the visual basic toolbox. (You can get the VB toolbox from the View menu). Now to add a reference to the web service . For this we will use the VB editor (Alt-F11). From the tools menu bar add the reference of Microsoft Soap tool kit. Now lets add the web service reference. For this click on the web reference in the tools menu of the VB editor. You can either search for a web service or if you know the URL of a web service u can directly add it. Now you are ready to access the web service. We can do this by creating an object of the web service class and displaying the result in the excel sheet.

Dim module As clsws_Service1
Dim value As String
Dim data() As String
Dim range1 As Range
Dim range2 As Range
Dim j As Integer
Set module = New clsws_Service1
value = module.wsm_getCapitals()
data = Split(value)
j = 0
Application.ActiveSheet.Range("A4").Activate
Set range1 = Range(Range("A4"), Range("A22"))
For Each range2 In range1
    If j < 9 Then
     range2.Offset(0, 3).value = data(j)
     range2.Offset(0, 4).value = data(j + 1)
     j = j + 2
   End If
Next range2

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Kodanda Pani

Web Developer

India India

Member

Working on .NET for last 6 years. Currently working for TCS.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 Pinmemberelomer5:00 28 Jul '10  
GeneralRe: My vote of 1 PinmemberKodanda Pani22:57 29 Dec '10  
GeneralWeb Service Toolkit Error Pinmembersmud14:05 13 Nov '06  
GeneralWeb services in Excel w/out programming Pinmemberdipskinny18:39 25 Sep '06  
GeneralSetting up the Webservices Pinmembergjenkin2:53 4 May '05  
GeneralRe: Setting up the Webservices PinmemberKodanda Pani18:36 4 May '05  
GeneralRe: Setting up the Webservices Pinmembergjenkin2:53 10 May '05  
GeneralRe: Setting up the Webservices.(Help Needed Immediately....) Pinsussuser353:44 27 Sep '05  
GeneralRe: Setting up the Webservices.(Help Needed Immediately....) Pinmembertakaka17:28 5 Nov '06  
QuestionSOAP Tool Kit? Pinmemberrball7:30 31 Mar '05  
AnswerRe: SOAP Tool Kit? PinmemberKodanda Pani19:17 3 Apr '05  
AnswerRe: SOAP Tool Kit? Pinmembergjenkin2:50 4 May '05  
GeneralRe: SOAP Tool Kit? Pinmemberchethana rao20:00 7 Apr '06  
GeneralRe: SOAP Tool Kit? PinmemberChiefOdie11:46 24 Oct '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 1 Sep 2003
Article Copyright 2003 by Kodanda Pani
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid