Bonjour à Tous.
Je souhaite réaliser un script qui me permettra d'automatiser les tâches suivantes sous BO
1. ouvrir BO (C'est fait)
2. lancer automatiquement une macro VBA BO associé à un rapport qui me permettra de
2.1. Rafraichir le rapport
2.2. enregistrer au format pdf
2.3. puis se referme.
2.4. inscrirre dans un fichier log l'événement
J'arrive à ouvrir BO automatiquement avec le répertoire qui lui est associé
Code->"D:\BI\BO_V6.5\BusinessObjects Enterprise 6\bin\busobj.exe" -user lico -pass lico -nologo "C:\Temp\BOReport.rep"
J'ai écris également le code VBA qui me permet de faire le 2 par contre il faut que je l'éxecute manuellement pour que ça marche.
Ma question est comment faire pour exécuter automatiquement une macro VBA associée à un rapport BO du nom par exemple BOReport.rep à l'ouverture de celui-ci sous BO v6.
VOICI CODE VBA DE BOReport.rep
Private Sub Document_AutoOpen()
ThisDocument.Rafraichir_pdf
End Sub
Public Sub Rafraichir_pdf()
Dim BoApp As busobj.Application, BODoc As busobj.Document, BORep As busobj.Report
Set BoApp = CreateObject("BusinessObjects.application.6")
''Dim objExcelApp As New Excel.Application
Dim objExcel As Object
'Création de Fichier Excel
''Set objExcelApp = New Excel.Application
'Ouverture fichier
''Set objExcel = objExcelApp.Workbooks.Open("c:\Temp\booknew.xls")
''objExcelApp.Visible = True
'Do stuff here
''Set objExcel = Nothing 'clears memory
'as
BoApp.Application.Interactive = False
BoApp.Application.BreakOnVBAError = False
With BoApp
'.LoginAs "lico", "lico"
.Visible = True
.Documents.Open ("C:\Temp\BOReport.rep")
With .ActiveDocument
.Refresh
''i = 1
''For Each rpt In .Reports
''rpt.Activate
'use the copyALL function
''BoApp.CmdBars(2).Controls("&Edit").Controls(20).Execute
'paste to excel
''Sheets(i).Range("A1").PasteSpecial Paste:=xlPasteValues
''i = i + 1
''Next
End With
End With
BoApp.ActiveDocument.SaveAs ("C:\Temp\save_pdf\BOReport.pdf")
'set variables to nothing
Set BoApp = Nothing
Set BODoc = Nothing
ThisDocument.Save
MsgBox "Sauvegarder avec succès OK"
busobj.Application.Quit
BoApp.Run "Rafraichir_pdf"
End Sub
Partager