BeckyL
I've done this in v4.1 of business objects using the scripting language. Although not quite VBA the principle should be the same.
The report I run has the last condition set to a supplier. The script then reads through a file to run the report for each supplier in the file.
In order to change the criteria in the report I delete the last condition and build a new one with the supplier from the file.
Example
-------
Rem ***************************************************************************
Rem *** Script to produce HTML for the Supplier Spend Report
Rem ***
Rem *** Author A.T.Pearson 15/11/2000
Rem ***
Rem *** File : Supplier_Spend.spt
Rem ***
Rem *** Notes
Rem *** -----
Rem ***
Rem 1 This works on the principle that the report has only 2 conditions
Rem *** the last condition (2nd in this case) is the condition that is deleted
Rem *** and re added
Rem ***
Rem 2 Make sure the input file does not have a blank line as the last record
Rem *** as this will try and create a query for it.
Rem ***************************************************************************
sub main
'********************************************************************************
' Declare
'********************************************************************************
Dim myApp As BOApplication
Dim myDocs As BODocuments
Dim myDoc As BODocument
Dim myReps As BOReports
Dim myRep as BOReport
Dim myDPs As BODataProviders
Dim myDP As BODataProvider
Dim myQueries As BOQueries
'********************************************************************************
' *** Set Environment
'********************************************************************************
Report = "Supplier_Spend"
Param_File = "H:\ProcNet_Parameters\" + Report + ".txt"
Output_Dir = "h:\BO_Report_Drop\Procurement\"
SheetNames = "Detail Spend|Spend By Site|Spend By Category|Ordering Patterns|Spend By Month"
'********************************************************************************
' This line is required for testing, when issued to DAS the report
' will already be open
' Application.Documents.Open(Report)
'********************************************************************************
'********************************************************************************
' Set current Document
'********************************************************************************
Set myApp = Application
Set myDocs = Application.Documents
Set myDoc = Application.Documents.Item(Report)
Set myReps = ActiveDocument.Reports
Set myRep = myReps.Item(1)
Set myDPs = myDoc.DataProviders
Set myDP = myDoc.DataProviders.item(1) ' 1st provider
'********************************************************************************
' Alter Query
'********************************************************************************
'
Dim myQuery1 As BOQuery
Dim myConditions1 As BOConditions
Dim myCondition1 As BOCondition
dim cnt as integer
dim Supps(400) as string
dim HtmlFile as String
'********************************************************************************
' Load Supps from File
'********************************************************************************
cnt = 0
Open Param_File for input as #1
do while not EOF(1)
cnt = cnt + 1
Line input #1,Supps(cnt)
loop
'********************************************************************************
for a = 1 to cnt
'Up load into Memory
myDP.Load
'Define Query
Set myQueries = myDP.Queries
'to AddQueryTechnique.
Set myQuery1 = myQueries.Item(1)
'Define the conditions of the first query.
Set myConditions1 = myQuery1.Conditions
'Remove 2nd condition (Supplier id)
myConditions1.remove(2)
'Add a condition
Set myCondition1 = myConditions1.Add("SUPPLIERS", "Supplier Id","In List",Supps(a),"Constant"
' Unload the data provider from memory and refresh it.
myDP.Unload
DoEvents
myDP.Refresh
'Export as HTML
HtmlFile = Output_Dir + mid$(Supps(a), 1,8)
'--------------------------------------------------------------
' Format of HTML command
' ----------------------
'
' objectvar.ExportShhetsAsHtml(fileName, "Sheet1|Sheet2|..."
' , graphs, borders, background
' , foreground, font, freeform, frames
' , autoRefresh, busobjdoc,[HtmlLayout])
'-----------------------------------------------------------------
call myDoc.ExportSheetsAsHtml(HtmlFile,SheetNames,1,1,1,1,1,1,1,0,0,0)
next a
end sub