Skip to Content
SAP Analysis for Microsoft Office

Advanced COM API via VBA


Please keep in mind that this feature is not officially documented and supported!

The features mentioned in that article are only for AO < 2.x. Starting with 2.0 the BiApi is not available anymore!

Additional to the VBA API described in the AO End User guide, Analysis for Office provides a tlb-file with enhanced COM functionalities. A type library (.tlb) is a binary file that stores information about a COM or DCOM object's properties and methods in a form that is accessible to other applications at runtime. Using a type library, an application can determine which interfaces an object supports, and invoke an object's interface methods. This document describes how to reference the tlb-file and how to access the functionalities. As an example this first part shows two simple functions you can use.

How to reference the API

You can reference the API by opening the “References” dialog in VBA. Select the file “BiApi.tlb” located in the installation folder of Analysis for Office.

After referencing this library the object browser (press F2) shows you the available classes.

General Coding

To access the functions you need the following general

Public mAO As Object

Sub Init()

On Error GoTo ErrorHandler

    Dim addIn As COMAddIn

    Dim automationObject As Object

    Set addIn = Application.COMAddIns("SBOP.AdvancedAnalysis.Addin.1")

    If addIn.Connect = False Then

       'start AO if not started yet

        addIn.Connect = True

    End If

    Set automationObject = addIn.Object

    Set mAO = automationObject.GetApplication()

    Exit Sub


    MsgBox ("Problem occurred")

End Sub

Function AO() As IApplication

    If mAO Is Nothing Then

        Call Init

    End If

    Set AO = mAO

End Function

Now you are able to call  methods on the mAO object.



This function returns all available connections for the
current workbook.

Sub ListOfConnections()
    Dim lEach As Variant
    Dim lList As Variant
    Dim aoCon As IConnection
    Dim lText As String

    Dim aoDoc As IDocument
    Set aoDoc = AO.GetActiveDocument()

    lList = aoDoc.GetConnections()

    For Each lEach In lList
      Set aoCon = lEach
      lText = lText + aoCon.SystemName +
               "; " + aoCon.SystemDescription + "; " + "connected:
               " + CStr(aoCon.IsConnected) + "; " + aoCon.RuntimeId + ";
               " + aoCon.BoeCuid + Chr(13)

    MsgBox (lText)
End Sub


To disconnect your workbook you can call the logout function on the active document

Sub Logout()

    Set aoDoc = AO.GetActiveDocument()

    Call aoDoc.Logout

End Sub

This is by the way a chance to implement the already in idea place requested feature “Disconnect” (640 B)
Former Member