Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use VBA in BO to provide report parameters 2

Status
Not open for further replies.

BeckyL

Technical User
May 18, 2001
10
0
0
US
Hello,

I am new to using Business Objects and have not found good examples of how to accomplish the task of passing variables to a BO report. I have used an array in VBA with Access to pass parameters and I am trying to do the same thing with a report in Business Objects. If anyone could assist me with this I would appreciate the help.

Becky L
 
Well, no one seems to be using VBA do this as yet. I have got the following code working but I need to know how to refresh the data in a report using a VBA command.
**********
Private Sub cmdRunRpts_Click()
'sets up the array
aPOSNO(0) = ("104828")
aPOSNO(1) = ("35511")

'initialize the POSNO variable
txtPOSNO = ("000000")

For Each txtPOSNO In aPOSNO
MsgBox Prompt:="POSNO Processing: " & txtPOSNO
' NEED CODE FOR THIS LINE TO REFRESH DATA IN THE REPORT.
ActiveReport.ExportAsPDF ("c:\becky\T-O Report-" & txtPOSNO & ".pdf")

Next txtPOSNO
***********

The code above will process the array variables and create the pdf files as specified but it does not refresh the data. I have tried multiple variations of statements in the area indicated but none have worked or they produce errors. Is there an equivalent in BO to the DoCmd.RunQuery command in Access?

Thanks in advance.
Becky
 
I have found the best source of examples for VBA is the BO Knowledge base. Documentation and exapmles from BO do seem to be a bit sparse. Just put VBA in the search criteria and have a browse. Have a look at Resolution #6988 which might be particularly helpful.
 
This is the example from BusinessObjects that I recommended:

How do you fill in the values of a prompt automatically, depending on the user login name, using VBA?

You created a report that prompts a user to select the values from the List of Values box.
You would like to know how you could fill in the values of the prompt automatically, depending on the user that is logged in.

You can use an "Open" event.
To use this, open the VBA editor by going to Tools > Macro > Visual Basic Editor. In the Project window, double click on "ThisDocument".
In the new window, select "Document" from the drop-down menu and "Open" in the right hand drop-down menu.

The following code is inserted in the window:

Private Sub Document_Open()
End Sub

Type in the following sample code between "Private Sub Document_Open()" and "End Sub":

Application.Interactive = False
Dim doc As Document
Set doc = Application.Documents.Open("NameOfYourDocument")
Dim myvar As String
myvar = Application.Variables.Item("BOUSER").Value
Select Case myvar
Case Is = "user1"
doc.Variables.Item("Which Country").Value = "France"
Case Is = "user2"
doc.Variables.Item("Which Country").Value = "US"
Case Is = "user3"
doc.Variables.Item("Which Country").Value = "Germany"
End Select
doc.Refresh
Application.Interactive = True

You must update "NameOfYourDocument" with the name of your document in:
Set doc = Application.Documents.Open("NameOfYourDocument")
and also change in Select Case statement the values for user1, user2, and user3 according to your local settings.


 
Endeavor,

Thank you for posting the article here. I am still waiting for the access to the knowledge base at BOb.

BeckyL
 
Hi,



i understood in report level we can call vba using macro .
but i want to use this vba in webi. as we can't create any macro's in webi.

can any one tell that how to call the VBA in object with in universe level.


Thank for help.
sjs2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top