|
Question : Quit Business Object Application through VBA
|
|
Hello everyone, hoping someone out there can help me with this one. Im having trouble doing the above. Within Excel VBA, I have a BO Report that gets a filter applied to it, then the data is exported to excel. This is done in a FOR statement. Once I come out of the FOR statement, I want to quit the BO application but for some reason it wont do it! Ive tried BOapp.quit, BOapp.application.quit etc. These have worked in the past when I simply open a BO document. Im only guessing but I think the code loses focus on the boapp when it comes out the FOR statement, so it cant find it. But I thought if it couldnt find it then it would error but it doesnt. Hope this makes sense to some of you.
|
|
Answer : Quit Business Object Application through VBA
|
|
Try this - I have added a couple of lines to destroy the FilterVar variables, and also moved the one to save the bodoc since you change the report filter after the first (original) save:
'Run BO Report - TOC_ReportingPacks_Promotions_Calls and apply filters Set boapp = CreateObject("BusinessObjects.application") boapp.Interactive = False boapp.LoginAs "Darryn", "passw0rd" boapp.Visible = False
Set bodoc = boapp.Documents.Open(BOFileLoc & "TOC_ReportingPacks_Promotions_Calls" & BOFileExtension) bodoc.Variables.Add("Begin Date").Value = BeginDate bodoc.Variables.Add("End Date").Value = EndDate bodoc.Refresh
For P = PromotionStart To PromotionEnd PromotionCode = ThisWorkbook.Worksheets("Parameters").Cells(P, TocCol).Value VDNList = ThisWorkbook.Worksheets("Parameters").Cells(P, TocCol + 1).Value '------------------------------------------------- 'now we have the filter, apply to BO Report Dim borpt As busobj.Report Dim myFilterVar As DocumentVariable Dim myFilterVar2 As DocumentVariable
Set borpt = bodoc.Reports.Item(1)
' Put your variable (or query object) here Set myFilterVar = bodoc.DocumentVariables("VDN") Set myFilterVar2 = bodoc.DocumentVariables("TOC Name") borpt.AddComplexFilter myFilterVar, "= = " & """" & VDNList & """" borpt.AddComplexFilter myFilterVar2, "= = " & """" & TOC & """" ' recompute the report borpt.ForceCompute borpt.ExportAsExcel (ExportFileLoc & Period & "\" & "TOC_ReportingPacks_Promotions_Calls_" & Period & ExcelFileExtension) borpt.AddComplexFilter myFilterVar, "=(1=1)" borpt.ForceCompute bodoc.Save
Next P Set myFilterVar = Nothing Set myFilterVar2 = Nothing set borpt = nothing bodoc.Close set bodoc = nothing boapp.Quit
Regards, Rory
|
|
|
|