Trigger - Integration with MS Office using VBA

We have created some VBA libraries (.bas and .cls) in order to ease the use of DUAS triggers for any external system development using VBA.

Introduction
We have created some VBA libraries (.bas and .cls) in order to ease the use of DUAS triggers for any external system development using VBA.

Prerequisites
In Office 2010, you will need to add the "Microsoft Scripting Runtime" and "Microsoft ActiveX Data Objects 2.8 library" as references via Tools > References in the VBA editor.
You will also need to import those 2 external libraries:

  • JSON.bas (from the VBJson library)

  • cStringBuilder.cls (from the VBJson library)


Quick Start
Use the full example file to try this example with Excel.
If you need to include the code in your existing VBA project you can import these modules:

  • DUASApi.bas

  • DUASApiParam.cls

  • DUASApiRespObj.cls

  • DUASApiRespObjElmt.cls


Description
Here is a sample of code showing how to use the libraries.
In the example below :

  • We first login to the Dollar Universe API and retrieve the token

  • We send an event

  • We log out


Sub Button1_Click()
...
' Login to the DUAS API
Set resp = DUASApi.loginDUASApi(host, port, login, pwd)
DUASApi.displayResponseInMsgBox resp
If resp.status = "success" Then

token = resp.token

'
Triggers an event to DUAS
Set resp = DUASApi.triggerEventDUASApi(host, port, token, eventType, params)
DUASApi.displayResponseInMsgBox resp

' Logout from DUAS API
Set resp = DUASApi.logoutDUASApi(host, port, token)
DUASApi.displayResponseInMsgBox resp

End If
...
End Sub


List of functions

Here's a list of all the functions from DUASApi.bas that you can use:



' Logins to the Dollar Universe API with a HTTP request
'

' Parameters
'
host The hostname of your DUAS server
' port The port number of your DUAS server
'
login login to connect to the Dollar Universe API
' pwd password to connect to the Dollar Universe API
'

' Returns: a structure containing all the information of the Dollar Universe API response
'

Public Function loginDUASApi(ByVal host As String, ByVal port As String, _
ByVal login As String, ByVal pwd As String) As DUASApiRespObj



Logs you in to the Dollar Universe API and returns a DUASApiRespObj which contains the return status and the authentication token if status is successfull


' Triggers an event on DUAS via the Dollar Universe API with an HTTP request
'

' Parameters
'
host The hostname of your DUAS server
' port The port number of your DUAS server
'
token The authentication token of your Dollar Universe API session
' eventType The event type defined in your trigger object in DUAS
'
params The list of parameters defined in your trigger object in DUAS
'
'
Returns: a structure containing all the information of the Dollar Universe API response
'
Public Function triggerEventDUASApi(ByVal host As String, ByVal port As String, _
ByVal token As String, ByVal eventType As String, ByVal params As Collection) As DUASApiRespObj


Sends an event to the Dollar Universe API: you need to provide the authentication token, the event type, and a list of optional parameters defined in your trigger.


'
'
Logout from the Dollar Universe API with an HTTP request
'
'
Parameters
' host The hostname of your DUAS server
'
port The port number of your DUAS server
' token The authentication token of your Dollar Universe API session
'

' Returns: a structure containing all the information of the Dollar Universe API response
'

Public Function logoutDUASApi(ByVal host As String, ByVal port As String, ByVal token As String) As DUASApiRespObj



Logs you out of the Dollar Unvierse API; it basically revokes the authentication token that you give as parameter



'
'
Displays in a MsgBox the structure containing all the information of an HTTP response from the Dollar Unvierse API
'
'
Parameters
' resp structure containing all the information of the Dollar Universe API response
'

Public Sub displayResponseInMsgBox(ByVal resp As DUASApiRespObj)



Displays as a MsgBox a response object from the Dollar Universe API



'
'
Displays and appends in an Excel Cell the structure containing all the information of an HTTP response from the Dollar Unvierse API
'
'
Parameters
' resp structure containing all the information of the Dollar Universe API response
'
WorksheetName The WorkSheet name of your Excel file
' row The row number of the Excel Cell in which you want to display the information
'
col The column number of the Excel Cell in which you want to display the information
'
Public Sub displayResponseAppendInCell(ByVal resp As DUASApiRespObj, _
ByVal WorksheetName As String, ByVal row As Integer, ByVal col As Integer)



Displays and appends in an Excel Cell a response object from the Dollar Universe API


Licences
We rely on an open library under BSD license called VBJson used to parse the JSON responses from DUAS.

Operating Systems


Versions

This plugin has no official releases yet

Created by....

A member of the Automic Community


Login to View or Leave Comments