VBA – Consume Soap Web Services

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on February 22, 2023



Are you looking for a way to integrate a web service with VBA? Download the unsupported Microsoft Office XP Web Services Toolkit 2.0 or Microsoft Office 2003 Web Services Toolkit 2.01

After doing so myself, I went browsing this Xmethods list for a public web service and found the Random Bushism Web Service. Now my goal was to create a Macro that would display a message box with a random “Bushism” in it, using the Web Services Toolkit.

consume

Some notes if you would like to try it yourself…

1. If you haven’t done so already, install the Web Services Toolkit.

2. Open Excel.

3. Open the Visual Basic Editor(Alt + F11).

4. Click the new option on your Tools menu – “Web Service References…”

consume1

5. In your newly opened Toolkit Form click the “Web Service URL” radio button and enter this address: http://greg.froh.ca/fun/random-bushism/soap/?wsdl

consume2

6. Click the search button.

7. Hopefully it has found the Bushism web service and listed it in the “Search Results” box. Place a checkmark to select the web service and click the “Add Button”.

consume3

8. Insert a module. Your Editor should now look something like this:

consume

9. Add this code to your module, sprinkle with error handling if desired, run or call the GetRandomBushism Macro:

Sub GetRandomBushism()

    Dim BushRandom As New clsws_RandomBushismService
    Dim BushStruct As struct_RandomBushism

    Set BushStruct = BushRandom.wsm_getRandomBushism

    MsgBox BushStruct.bushism & vbCrLf & _

    vbCrLf & BushStruct.context, , "Bushism"

End Sub

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!


<<Return to VBA Examples

vba-free-addin

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples