Download and install the Microsoft Office Web Service
Toolkit from Microsoft,
if you haven't already.
Start Microsoft Excel.
Open a new worksheet.
Using the Control Toolbox, create
an Excel graphics window by dropping and dragging an Image.
Drag a Command Button into the
window. You use this button to trigger the Web service call and load
the graphic. At this stage, the window looks like this.

Double-click the Command Button button
and the VBA editor starts.
Select Tools > Web Service References.
Note
The Web Service References option
is available only if you install the Microsoft Office Web Service
Toolkit. |
In Web Service URL, type the
WSDL that was referenced in Using Web Services:
"http://localhost:3465/SurfPeaksWebServiceServer/Service.asmx?WSDL"
Click Search to query the Web
service. The result resembles this.

Select the appropriate service in the Search
Results pane and click Add to bind
it to your project. Notice that a Class Module is created called clsws_Service.
This module will be used by the button action to retrieve the data.
In the worksheet, for the method CommandButton1_Click(),
add and save the following code:
Sheet1.Image1.Picture = Nothing
Dim value() As Byte
Set module = New clsws_Service
value = module.wsm_SurfPeaksWebService
'Saves byte() data from web service to a file
Dim intFileNumber As Integer
intFileNumber = FreeFile
Open "c:\temp1.png" For Binary As #intFileNumber
Put intFileNumber, , value
Close #intFileNumber
'Loads the saved picture into the image
Sheet1.Image1.Picture = LoadPicture("c:\temp1.png")
Click the command to display the following in the
graphics pane of your worksheet.
Tip
You may need to close Microsoft Excel and reopen it to see the
graphic. |
