I want to call a VBA macro to copy contents of BO report to excel when i choose run macro menu option from the report..
any sample code for starting on this...
Sub GetBOData()
Dim XLApp As Excel.Application, XLWb As Excel.Workbook
Set XLApp = CreateObject("Excel.application"
With XLApp
set XLWb = .workbooks.add
end with
with activedocument
with .activereport
BoApp.CmdBars(2).Controls("&Edit".Controls(20).Execute
end with
with XLApp.XLWb
.Sheets(1).Range("A1".PasteSpecial Paste:=xlPasteValues
End With
Set XLApp = Nothing
Set XLWb = Nothing
End Sub
Rgds, Geoff [blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
Dim BoApp As busobj.Application, BODoc As busobj.Document, BORep As busobj.Report
Set BoApp = CreateObject("BusinessObjects.application"
Dim objExcelApp As New Excel.Application
Dim objExcel As Object
'create Excel
Set objExcelApp = New Excel.Application
'open file
Set objExcel = objExcelApp.Workbooks.Open("c:\temp\booknew.xls"
objExcelApp.Visible = True
'Do stuff here
Set objExcel = Nothing 'clears memory
'as
With BoApp
'.LoginAs "Username", "password"
'.Visible = True
'.Documents.Open ("D:\Pritpal\Business Obj - Try\Document1.rep"
With .ActiveDocument
'.Refresh
i = 1
For Each rpt In .Reports
rpt.Activate
'use the copyALL function
BoApp.CmdBars(2).Controls("&Edit".Controls(20).Execute
'paste to excel
Sheets(i).Range("A1".PasteSpecial Paste:=xlPasteValues
i = i + 1
Next
End With
End With
BoApp.ActiveDocument.SaveAs ("D:\Pritpal\Business Obj - Try\Document1.pdf"
'set variables to nothing
Set BoApp = Nothing
Set BODoc = Nothing
Kprit - That looks awful like some code I posted for interacting with BO FROM excel. If this was from BO to Excel, you wopuldn't need to declare the BO variables (BOApp etc)
You certainly wouldn'yt use this line:
Set objExcel = Nothing 'clears memory
in the middle of the code as it resets the excel variable to nothing
And this won't work as you would already be in Business Objects:
With BoApp
'.LoginAs "Username", "password"
'.Visible = True
'.Documents.Open ("D:\Pritpal\Business Obj - Try\Document1.rep"
Sorry but it looks like you have mixed up 2 bits of code - one for pushing data out to excel from BO and one for pulling data into excel, using BO as the extraction tool
Rgds, Geoff [blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
Is CopyAll disabled when you go into Business Objects normally (manually) ?
Rgds, Geoff [blue]Experience is something you don't get until just after you need it[/blue]
We want to help [red]you[/red] Help us by reading this FAQ 1st faq222-2244
Very bizarre - I can't really help you there as it all works fine when I open business objects through code....Could it be a function of the userID you are opening objects with via code ??
Could you post the code you are using ??
Rgds, Geoff [blue]Experience is something you don't get until just after you need it[/blue]
We want to help [red]you[/red] Help us by reading this FAQ 1st faq222-2244
Can't really see anything wrong there - as I alluded to before - could it be a function of the userID that you are trying to log in as ?? Some userIDs may have only limited access to BO functionality....
Rgds, Geoff [blue]Experience is something you don't get until just after you need it[/blue]
We want to help [red]you[/red] Help us by reading this FAQ 1st faq222-2244
I'm out of ideas in that case - maybe a look at the BO knowledgebase might throw some light on the issue....
Rgds, Geoff [blue]Experience is something you don't get until just after you need it[/blue]
We want to help [red]you[/red] Help us by reading this FAQ 1st faq222-2244
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.