Hi,
here is my code solving this issue.
It automates Deski from Excel (2007 or above). You may find instructions in the comments.
'Use this code in Excel2007 or above
'Prerequisite: BusinessObjects XI 3.1 properly installed on your PC
'You MUST add reference to "BusinessObjects 12.0 Object Library" prior to use the code below (Tools\References)
'You should paste this code into an Excel worksheet (or ThisWorkbook) code module (Excel2007 or above)
'If the Immediate window not seen in your VBIDE then: View\Immediate Window
'Change CMSSourceFolder, CMSDestinationFolder, RepName
'Save your workbook as a Macro-Enabled Workbook (i.e. ROOtest.xlsm)
'Run the SetROO subroutine
Option Explicit
Option Base 1
'This macro implements Deski Application & Document level events as described in the following document:
'"Desktop Intelligence Developer Guide BusinessObjects XI 3.1" , Chapter: "Desktop Intelligence events"
Private WithEvents iDoc As busobj.Document 'Deski Doc with events
Private WithEvents boApp As busobj.Application 'Deski App with events
Dim bAuth As Boolean 'Logon success
Private CMSSourceFolder As String, CMSDestinationFolder As String
Private RepName As String, RepFullName As String
Private CategoryList As String
Private bDebug As Boolean 'Show/suppress event messages
Private bboApp_DocumentBeforeRefresh As Boolean
Private DPIsRefreshable() As Boolean 'Stores dataproviders' IsRefreshable property
Private i As Long 'For DPs cycle
Private Sub SetROO()
On Error GoTo ErrorHandler
Application.DisplayAlerts = False
bDebug = True 'If you do not want to see the event messages change it to False
Set boApp = New busobj.Application
boApp.Visible = True 'We shall see what's going on in Deski
boApp.Interactive = True 'For LogonDialog
bAuth = boApp.LogonDialog
CMSSourceFolder = "XARCH/ROO" 'Change your source folder path
CMSDestinationFolder = "XARCH/ROO" 'Change your destination folder path (may be same as source folder)
RepName = "D01Toroltek_3" 'Change your test report name here
bboApp_DocumentBeforeRefresh = False
Debug.Print Time, "Action: OpenFromEnterprise" & " ,CMSSourceFolder - " & CMSSourceFolder & " ,RepName - " & RepName
Set iDoc = boApp.Documents.OpenFromEnterprise(RepName, CMSSourceFolder, BoEnterpriseFolderKind.BOFolder)
boApp.Interactive = False 'Suppress alerts, questions,...
RepFullName = iDoc.FullName
CategoryList = iDoc.DocAgentOption.CategoryList & "|AutoRefreshDisabled"
Debug.Print Time, "Action: AutoRefreshWhenOpening set to False", iDoc.FullName
iDoc.AutoRefreshWhenOpening = False 'ROO set False explicitly
Debug.Print Time, "Action: iDoc.SaveToEnterprise - " & CMSDestinationFolder & "/" & RepName, iDoc.AutoRefreshWhenOpening
iDoc.SaveToEnterprise CMSDestinationFolder, BoEnterpriseFolderKind.BOFolder, CategoryList, "", True
Debug.Print Time, "Action: iDoc.Close (boDontSave)", iDoc.FullName, iDoc.AutoRefreshWhenOpening
iDoc.Close (boDontSave)
Debug.Print Time, "Action: ReOpenFromEnterprise - " & CMSDestinationFolder & "/" & RepName
Set iDoc = boApp.Documents.OpenFromEnterprise(RepName, CMSDestinationFolder, BoEnterpriseFolderKind.BOFolder)
DocClose:
Debug.Print Time, "Action: iDoc.Close (boDontSave)", iDoc.FullName, iDoc.AutoRefreshWhenOpening
iDoc.Close (boDontSave)
CleanUp:
On Error Resume Next
Application.DisplayAlerts = True
Set iDoc = Nothing
If Not boApp Is Nothing Then boApp.Quit
Set boApp = Nothing
Exit Sub
ErrorHandler:
Debug.Print "ERROR! Err.Number: " & Err.Number & ",Err.Description: " & Err.Description & ". Going to clean up."
Err.Clear
Resume CleanUp
End Sub
'----------------------------------------------------
'Implementing Deski Document level events
Private Sub iDoc_Activate()
If bDebug Then Debug.Print Time, "Event : iDoc_Activate", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_AfterRefresh()
If bDebug Then Debug.Print Time, "Event : iDoc_AfterRefresh", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_BeforeClose(Cancel As Boolean)
Debug.Print Time, "Event : iDoc_BeforeClose", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_BeforeRefresh(Cancel As Boolean)
If bDebug Then Debug.Print Time, "Event : iDoc_BeforeRefresh", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_BeforeSave(Cancel As Boolean)
If bDebug Then Debug.Print Time, "Event : iDoc_BeforeSave", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_Deactivate()
If bDebug Then Debug.Print Time, "Event : iDoc_Deactivate", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
Private Sub iDoc_Open()
If bDebug Then Debug.Print Time, "Event : iDoc_Open", iDoc.FullName, iDoc.AutoRefreshWhenOpening
End Sub
'----------------------------------------------------
'Implementing Deski Application level events
Private Sub boApp_DocumentActivate(ByVal doc As busobj.IDocument)
If bDebug Then Debug.Print Time, "Event : boApp_DocumentActivate - " & doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentAfterRefresh(ByVal doc As busobj.IDocument)
If bDebug Then Debug.Print Time, "Event : boApp_DocumentAfterRefresh", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentBeforeClose(ByVal doc As busobj.IDocument, Cancel As Boolean)
If bDebug Then Debug.Print Time, "Event : boApp_DocumentBeforeClose", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentBeforeRefresh(ByVal doc As busobj.IDocument, Cancel As Boolean)
'If ROO (AutoRefreshWhenOpening property) is True than this is the very first event
'1. All DataProviders IsRrefreshable property stored in DPIsRefreshable()
'2. All DataProviders IsRrefreshable property set to False so the DOCUMENT WILL NOT BE REFRESHED ANYWAY
If bDebug Then Debug.Print Time, "Event : boApp_DocumentBeforeRefresh", doc.FullName, doc.AutoRefreshWhenOpening
ReDim DPIsRefreshable(doc.DataProviders.Count)
bboApp_DocumentBeforeRefresh = True
For i = 1 To UBound(DPIsRefreshable)
With doc.DataProviders(i)
If bDebug Then Debug.Print Time, "Action: DataProvider " & .Name & " IsRefreshable property stored & set to False."
DPIsRefreshable(i) = .IsRefreshable
.IsRefreshable = False
End With
Next i
End Sub
Private Sub boApp_DocumentBeforeSave(ByVal doc As busobj.IDocument, Cancel As Boolean)
'All DataProviders IsRrefreshable property restored from DPIsRefreshable()
If bDebug Then Debug.Print Time, "Event : boApp_DocumentBeforeSave", doc.FullName, doc.AutoRefreshWhenOpening
If bboApp_DocumentBeforeRefresh Then
For i = 1 To UBound(DPIsRefreshable)
With doc.DataProviders(i)
If bDebug Then Debug.Print Time, "Action: DataProvider " & .Name & " IsRefreshable property restored - " & DPIsRefreshable(i)
.IsRefreshable = DPIsRefreshable(i)
End With
Next i
End If
End Sub
Private Sub boApp_DocumentDeactivate(ByVal doc As busobj.IDocument)
If bDebug Then Debug.Print Time, "Event : boApp_DocumentDeactivate", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_NewDocument(ByVal doc As busobj.IDocument)
If bDebug Then Debug.Print Time, "boApp_NewDocument", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
Private Sub boApp_DocumentOpen(ByVal doc As busobj.IDocument)
If bDebug Then Debug.Print Time, "Event : boApp_DocumentOpen", doc.FullName, doc.AutoRefreshWhenOpening
End Sub
SuKA (BOB member since 2018-10-20)