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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating a Business Objects report 1

Status
Not open for further replies.

funkmonsteruk

IS-IT--Management
Feb 8, 2002
210
GB
I have two business objects reports which i need to run (and refresh) and print at the same time evryday. Is it possible to add either a VBA macro or some other function to the document that will perform this task automatically.

It would also be good if i could get the reports to save each time they are run using the date saved as a filename. Any help that anyone can offer me will be gratefully appreciated.
 
Hello funkmonsteruk ,

Just for the purposes you mention BO has an tool called 'Broadcast Agent' which lets you schedule your reports. T. Blom
Information analist
Shimano Europe
tbl@shimano-eu.com
 
Here's some code that will refresh the data, save it, print the report, and then export it to a text file.(You can remove the export part, I just threw it in so you'd see there's lots you can do) I don't use the print part, but I'm pretty sure it prints to whatever default you have set up. The code below is for 2 reports, but you could do it with more than that(I have it running with 8 successfully)

I'm using BO 5.1.2, so if your version is different you may have to modify how you do this:

Go into BO and open your first report. Go to Tools|Macro, and choose Visual Basic Editor.
Then go to View|Code.

Type this into your module:

Private Sub Document_Open()
Dim Doc As Document
Dim Rep As Report

Set Doc = Application.Documents.Item(1)
Doc.Refresh
Doc.Save
Doc.Print
Set Rep = Doc.Reports.Item(1)
Rep.ExportAsText("C:\Path to your file\YourReportName1")

Set Doc = Application.Documents.Item("YourReportName2")
Doc.Refresh
Doc.Save
Doc.Print
Set Rep = Doc.Reports.Item(1)
Rep.ExportAsText("C:\Path to your file\YourReportName2")
Doc.Close

Application.Quit

End Sub

Then, go to the Start menu of your the computer that will be running the reports, right click and choose Explore. Find "Sheduled Tasks". Add a scheduled task to run the 1st report at your scheduled time.

You can put user id and password, etc in the command line if you want it totally automated... but you'll have to watch the first time you do it, because of the prompt for "report contains macros". You'll have to deselect the box to always ask, and then click on enable macros.

Hope that helps,
ainkca
 
Thanx for your help ainca, this works fine , however i'm having trouble adding my user ID and password to the command line, any suggestions
 
Create a new shortcut with this command line in the 'Target'

"C:\Program Files\Business Objects\BusinessObjects 5.0\BUSOBJ.EXE" -user USER -pass PASSWORD -nologo "C:\Program Files\Business Objects\BusinessObjects 5.0\UserDocs\ReportName.rep"

The path to your BUSOBJ.EXE file may be different of course, you may need to adjust.
Change USER to your user ID, and PASSWORD to the password for that user.
the -nologo makes the splash screen not appear.
Change ReportName.rep to your report name.


Then, the 'Start in' line should be:
"C:\Program Files\Business Objects\BusinessObjects 5.0\UserDocs"
(or whatever the appropriate path is)

Hope that works for you!
 
Hi,
I saw this and I tried to print a report c:\BOFirst, by running the code from VBE. ( The macro is saved). but not able to print and export the report. Even I added this to windows scheduler as c:\BOFirst. but giving Not able to run.

Can you help me..

THanks
 
Can you paste the exact code of your macro in here so I can see it?


 
Private Sub Document_Open()
Dim Doc As Document
Dim Rep As Report

Set Doc = Application.Documents.Item(1)
Doc.Refresh
Doc.Save
Doc.Print
Set Rep = Doc.Reports.Item(1)
Rep.ExportAsText ("C:\srinivas\BOFirst.txt")

'Set Doc = Application.Documents.Item("YourReportName2")
'Doc.Refresh
'Doc.Save
'Doc.Print
'Set Rep = Doc.Reports.Item(1)
'Rep.ExportAsText ("C:\Path to your file\YourReportName2")

Doc.Close

Application.Quit
End Sub
 
I added this code as a macro. Where project and document will be stored. Also can you please explain me what are these document properties in appearing VBE.
IsAddin - T/F
Installed - bonotinstalled, boinstalled, boinstalledandlocked

Thanks
 
OK... that part looks right.
What happens when you open Business Objects, then open the report with that code in it? Does the text file get created in the path you specified?

If so, then your problem lies in the automation somewhere.

I'd start with creating an icon that will run it first using the steps in my Aug 28th post in this thread. If that works, then the problem is in the scheduling.

Try those things and let's see where we are.
 
I opened the report by checking enable macros.
VBE is opened in debug mode at the line DOC.Print - Cannot execute.. I commented and it generated the text file.
Doc.close - Cannot execute the command.

I close the report and again I opened. Now it is giving
Invalid object at Set Doc = Application.Documents.Item(1) even though I changed it to Set Doc = Application.Documents.Item("BOFirst")

Hope problem with Automation. Any way I understand some thing.. Can you give me some suggestion how macros can be used separately created not using VBE.

Thanks

 
Ok, that sounds more like a problem with the reference library.

While inside of the Visual Basic Editor, click on the Tools menu, and choose References.

See if any of the checked items have MISSING: xxxxxx
If so, make a note of which one it is. Then deslect it, and click OK.
Then go back into references again, and select it again. Click OK, and then try running your code again.

You'll want to make sure you have Visual Basic for Applications checked, and Business Objects 5.1 Object Library(or whatever version you're on). I have a few others, but I think it's probably one of these giving you trouble.

As an aside, I'm not sure if Doc.Print will work, I think it has to be something like Doc.PrintOut (&quot;\\<path to printer>\<printer name>&quot;) Still trying to work that one out myself.

Try the references and let me know. Off to a meeting for a bit...
 
What else is there as a reference?

Also, you could try copying over the .dlls for those two references in case one of them is corrupt.

What version of BO are you on?
 
Visual Basic for Applications
Businsess objects 5.1 library
OLE Automation
These 3 are there as references. (Even I removed OLE automation.. getting same problem).
Iam using BO 5.1
I cannot copy dll files.. as they will be installed from network server by network people.

Thanks

 
The only one I have that you don't is:

Microsoft Forms 2.0 Object Library

Can't see that that would be it, but you never know. Give it a try(add as another reference).

By the way, using Doc.PrintOut will work (prints to default).
 
Try taking out the Doc.close and try using Application.Quit instead. I wonder if maybe it's not liking that the code is in the same document you're trying to close. I seem to remember quite a long time ago having to remove that line from some of my code. I only use Doc.close when I'm running &quot;multiple&quot; reports from within the same report.

You'll notice that in my first example the Doc.Close is for the second report... not the first. The first report gets closed using Application.Quit.

 
Hi,
I removed it and it is working now.. So now how can i schedule this..

Thanks
 
Go to the Start menu, right click and choose Explore. Find &quot;Sheduled Tasks&quot;. Add a scheduled task to run the report at your scheduled time.

You can add the -user USERID -pass PASSWORD etc as described above(in this thread0 in the command line of your scheduled task. Since the problem wasn't in the scheduling, if you already did that part it may work now.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top