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

Exporting Automatically To Excel

Status
Not open for further replies.

daniribs7

Technical User
Aug 13, 2003
17
0
0
ZA
I currently have a BO report which refreshes on a dailly basis and save/re-writes itself back to the server. Is it possible for this file t export to excel/txt/csv automatically as well when it refreshes?

If so, how?

Thanks in advance.
 
Certainly is, you'll need to stick some vba code into the after refresh document action.

Your code will probably be something like this:

Dim Doc As Document
Dim Rep As Report
Set Doc = Application.Documents.Item(1)
Set Rep = Doc.Reports.Item(1)
Rep.ExportAsText ("Filepath\Filename" + ".xls")

should do the trick
[soapbox]
 
VBA ???
A Macro currently does this, is it the same thing?

sorry, I'm pretty new to all this, code of Macro:
Application.Documents.Open("E:\TEMP.rep")
Application.Documents.Open("E:\TEMP.rep").Refresh
Application.Documents.Open("E:\TEMP.rep").Save
Application.Documents.Open("E:\TEMP.rep").SaveAs "E:\TEMP.rep", True
Application.Documents.Open("E:\TEMP.rep").Close

Thanks
 
VBA? Visual Basic for Applications - most macros use this as the're language.

Right click in your Business Objects toolbar, select Visual Basic Toolbar, click on the white box with the bluetop and red bit coming out of top (Visual Basic Editor)

The code goes into a window on the right hand side of the visual basic editor.

You need to insert the code into a sub routine, you can make your own or use one of the docuement event ones....

The above code seems to save the report as a BO report as opposed to converting it to excel.

A basic rundown of what my coding does

dim doc as document
dim rep as report

declares two variables one relating to a document one relating to a report

set doc and set rep declares what these variables should be

Rep.ExportAsText ("Filepath\Filename" + ".xls") exports the document as text but because of the.xls tag the information is put into a spreadsheet (text delimited)

 
Your macro code is refreshing your document and saving that document as Business Objects document. After refreshing your Buiness Objects document, you have to export it to excel.
 
Would it be possible to edit my code and do the following:

Application.Documents.Open("E:\TEMP.rep")
Application.Documents.Open("E:\TEMP.rep").Refresh
Application.Documents.Open("E:\TEMP.rep").Save
Application.Documents.Open("E:\TEMP.rep").SaveAs "E:\TEMP.rep", True
Application.ExportAsText("Filepath\Filename" + ".xls")
Application.Documents.Open("E:\TEMP.rep").Close

I've added the code converning the Visual Basic in, how do I get this to deploy automatically when the file refreshes?

thanks again
 
I need to know how to run the macro automatically every the report refreshes, does anybody know how?

thanks
 
Call the macro in the Document_AfterRefresh or AfterRefresh method.

Private Sub Document_AfterRefresh()
'Call the macro here
End Sub

Good Luck
Sri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top