我需要每天发布一个业务对象报告,修改一个名为" Phone"的维度中的电话号码列表。我想有一个Excel文件,我在BO宇宙中设置我想要查找的电话号码,启动报告并保存结果。我修改了一个我发现的例子,但我不知道如何使用报告的VBA代码修改条件。如果我只是想刷新报告,它可以正常工作,但从不添加或更新条件的值。任何的想法?
在我的Excel中,我在单元格中有信息,我将其作为变量传递给VBA函数:
C2 = Business Object login
C3 = Business Object password
C4 = BO report path
C5 = Exported results path
C6 = list of phone numbers separated with "," o ";" (whatever is needed)
我从Excel运行的VBA代码:
Sub Exec_BO_Query()
Dim BoApp As Object
On Error Resume Next
Set BoApp = CreateObject("BusinessObjects.application")
With BoApp
.Visible = True
.LoginAs Worksheets("Configuration").Range("C2").Value, Worksheets("Configuration").Range("C3").Value, False
.Documents.Open (Worksheets("Configuration").Range("C4").Value)
With .ActiveDocument
.Queries.Item(1).Conditions.Add "Phone number", "Phone", "In list", Worksheets("Configuration").Range("C6").Value
.Refresh
.SaveAs Worksheets("Configuration").Range("C5").Value
.Close
End With
.Application.Quit
End With
Set BoApp = Nothing
Workbooks(ThisWorkbook.Name).RefreshAll
End Sub
我不知道如何正确使用条件(即使我不知道是否是正确的使用对象)。根据文档的语法是这样的:
var.Add(class, objectorcondition, [operator], [operand1], [operand1type], [operand2], [operand2type])
var is the name of the Conditions variable that you declare.
class is a string that identifies the class.
objectorcondition is a string that identifies the condition.
operator identifies the operation. This parameter is optional.
operand1, operand2 are each operands for the condition. These parameters are optional.
operand1type, operand2type are each operand types for the corresponding operator. These parameters are optional.
感谢您的帮助!