|
Question : VBA - Business Objects Interaction
|
|
Hi, I have taken over a project, and hae been left no notes or documentation related to the project! I am trying to fix a pretty complex system. The first problem I have encountered user the software package business objects. I need to be able to log into this via VBA. I asume this has been working previously, but not now. I get an error; User Defined Type not defined. On this line "Set pm_objApp = New busobj.Application"
Can anyone help. I have never done this before?
Public Function BusinessObjectsOutput(ByVal strUserName As String, ByVal strPassword As String, Optional arrParams As Variant) As Boolean On Error GoTo ErrorHandler Dim objApp As Object Dim objRpt As Object Dim objDoc As Object Dim objVar As Object Dim arrParam As Variant Dim i As Integer Dim mbBoWasRunning As Boolean If docPath = vbNullString Then Err.Raise vbObjectError + 1001, "clsBusinessObjects.ExportToText", "No document path has been specified." On Error Resume Next mbBoWasRunning = True Set pm_objApp = GetObject(, "busobj.Application") On Error GoTo ErrorHandler If pm_objApp Is Nothing Then Set pm_objApp = New busobj.Application ' CreateObject("BusinessObjects.Application") ', "C:\Program Files\Business-Objects-5-1-8\BusinessObjects 5.0\BUSOBJ.EXE") 'New busobj.Application mbBoWasRunning = False End If pm_objApp.Interactive = False Forms!frmlogger.LogMessage "Logging on to Business Objects server" If pm_objApp.LoginAs(strUserName, strPassword) Then Forms!frmlogger.LogMessage "Opening Business Objects report" Set objDoc = pm_objApp.Documents.Open(docPath) With objDoc Forms!frmlogger.LogMessage "Setting Business Object report parameters" If IsArray(arrParams) Then For i = LBound(arrParams) To UBound(arrParams) arrParam = arrParams(i) For Each objVar In objDoc.Variables If objVar.Name = arrParam(0) Then objVar.Value = arrParam(1) Exit For End If Next Next End If .Refresh ' Forms!frmlogger.LogMessage "Report parameters set, saving document" ' .Save ' Forms!frmlogger.LogMessage "Document saved!" Forms!frmlogger.LogMessage "Exporting Business Objects data" If Not ExportToText(objDoc) Then Err.Raise vbObjectError + 1001, "clsBusinessObjects.BusinessObjectsOutput", Err.Description BusinessObjectsOutput = True Forms!frmlogger.LogMessage "Business Objects data successfully exported, closing document" .Close Forms!frmlogger.LogMessage "Document closed" End With Else Err.Raise vbObjectError + 1001, "clsBusinessObjects.BusinessObjectsOutput", "Login failed, terminating!" End If Exit_This: On Error Resume Next objDoc.Close Set objDoc = Nothing If Not mbBoWasRunning Then pm_objApp.Quit Set pm_objApp = Nothing End If Exit Function ErrorHandler: Forms!frmlogger.LogMessage Err.Number & " - " & Err.Description, 0 Err.Raise vbObjectError + 1001, "clsBusinessObjects.BusinessObjectsOutput", Err.Description Resume Exit_This End Function
|
|
Answer : VBA - Business Objects Interaction
|
|
Have you set a reference to the Business Object library?
Tools/References while in a module
|
|
|
|