Beispiel - Code für die Verarbeitung außerhalb von VBA

Sie können IBM® Cognos® Office Automation außerhalb von VBA verwenden. Die APIs können nicht direkt aufgerufen werden.

Sie müssen Wrapper-Makros im Microsoft Office-Dokument für jede API erstellen. Diese Makros können Sie dann über Ihren Code aufrufen. Das Modul CognosOfficeAutomationExample.bas ist ein Beispiel für Wrapper-Makros, die außerhalb von VBA aufgerufen werden können.

Das folgende Visual Basic-Script öffnet Microsoft Office Excel, meldet sich bei IBM Cognos Analyticsan, aktualisiert den Inhalt und meldet sich ab.

' Start Excel in batch mode
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.ScreenUpdating = False
objExcel.DisplayAlerts = False
'Open a workbook that has IBM Cognos data
in it.
Set objWorkbook = objExcel.Workbooks.Open("C:\workbook1.xls")
' Call the wrapper macros
objExcel.Run "Logon", "http://localhost/ibmcognos/bi/v1/disp",
"Administrator", "", "Production"
objExcel.Run "RefreshAllData"
objExcel.Run "Logoff"
objExcel.Run "TraceLog", "C:\AutomationLog.log"
objWorkbook.Save
objWorkbook.Close
objExcel.Quit