Developers Cookbook

VBA Client Example (Excel, in this case)

This implementation requires Microsoft's MSSOAP toolkit, available from the microsoft download centre. Follow the instructions to install this toolkit on your system.

This example uses BankVal UK's bankvalidate method, but the same technique may be used to access any other BankVal method simply by substituting the method name. Please bear in mind that for the getbranchdetails and cardvalidate methods, the parameter string differs from the one shown in this example. For further information about the other methods available, please see: Technical Details

This example is also applicable to our BankVal International web service, which may be used to validate International Bank Account Numbers (IBAN) and SWIFT Bank Identifier Codes (BIC). To do this, follow the steps shown below, replacing the strings :-


The method names available for BankVal International are swiftvalidate and ibanvalidate. Substitute bankvalidate in the code excerpt with the method you wish to use. Information on the parameter string formats for swiftvalidate and ibanvalidate can be found at: Technical details

This example makes use of the backup system to ensure seamless operation in the event of a problem. This is strongly recommended.

1 Create a macro for your worksheet. Click Tools -> Macro to do this.

2 In the Macro Editor, click Tools ->References and check the highlighted references shown below:

Macro Editor

3 Click 'OK' and insert the following VBA code using the Macro Editor:

Sub validatebankdetails()
Dim paramstring As String
Dim soapClient1
Dim soapClient2
Dim usebackup As Boolean

Set soapClient1 = CreateObject("MSSOAP.SoapClient30")

On Error Resume Next

'Assemble the parameter string
paramstring = Sheet1.Cells(1, 2) & "|" & Sheet1.Cells(2, 2) & _ 
"|" & Sheet1.Cells(3, 2) & "|" & Sheet1.Cells(4, 2)

'Create an instance of soapClient1, referring to the primary service
soapClient1.ClientProperty("ServerHTTPRequest") = True
Call soapClient1.MSSoapInit _

If Err <> 0 Then
'There was a problem, so we need to call the backup service
Set soapClient2 = CreateObject("MSSOAP.SoapClient30")
soapClient2.ClientProperty("ServerHTTPRequest") = True
Call soapClient2.MSSoapInit _
usebackup = True
End If

If usebackup = False Then
Sheet1.Cells(5, 2) = soapClient1.bankvalidate(paramstring)
Sheet1.Cells(5, 2) = soapClient2.bankvalidate(paramstring)
End If

End Sub

<< back to top >>

Our customers