Ian Bartlett
New Member
- Joined
- Jul 16, 2002
- Messages
- 7
All,
I'm running Win 7, Excel 2010 and Business Objects 6.5.
I'm attempting to run a VBA script in Excel to start Business Objects, open a file, refresh it and then extract the data into Excel.
What I have so far, working fine, is this:
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Open_BO_and_Rep()<br>****<br>****<SPAN style="color:#00007F">Dim</SPAN> BOApp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN><br><br>****<SPAN style="color:#00007F">Set</SPAN> BOApp = CreateObject("BusinessObjects.application")<br><br>****<SPAN style="color:#00007F">With</SPAN> BOApp<br>********.Visible = <SPAN style="color:#00007F">True</SPAN><br>********.LoginAs "Username", "Password"<br>********.Documents.Open ("E:\Graph Book.rep")<br>********<br>********<SPAN style="color:#00007F">With</SPAN> .ActiveDocument<br>************.Refresh<br>********<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>****<br>****<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
This opens BO & the required file, and refreshes it. So far, so good.
My problem lies with the next step, of getting the data from the refreshed BO report into Excel.
I found this code:
<font face=Courier New>****<SPAN style="color:#00007F">With</SPAN> .ActiveDocument<br>********.Refresh<br>********i = 1<br>********<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> rpt <SPAN style="color:#00007F">In</SPAN> .Reports<br>****************rpt.Activate<br>****************BOApp.CmdBars(2).Controls("&Edit").Controls(20).Execute<br>****************Sheets(i).Range("A1").PasteSpecial Paste:=xlPasteValues<br>************i = i + 1<br>********<SPAN style="color:#00007F">Next</SPAN><br>****<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN></FONT>
which should select all / copy all in the BO report, and then paste it into Excel. I can't get it to work. I receive the error "Paste Special method of range class failed" at the "Sheets(i).Range("A1").PasteSpecial Paste:=xlPasteValues" line.
I found references to "adding BO to the Excel library", but I couldn't find how to do this and I'm not sure if this is the cause.
Could anyone help please?
Ian
I'm running Win 7, Excel 2010 and Business Objects 6.5.
I'm attempting to run a VBA script in Excel to start Business Objects, open a file, refresh it and then extract the data into Excel.
What I have so far, working fine, is this:
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Open_BO_and_Rep()<br>****<br>****<SPAN style="color:#00007F">Dim</SPAN> BOApp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN><br><br>****<SPAN style="color:#00007F">Set</SPAN> BOApp = CreateObject("BusinessObjects.application")<br><br>****<SPAN style="color:#00007F">With</SPAN> BOApp<br>********.Visible = <SPAN style="color:#00007F">True</SPAN><br>********.LoginAs "Username", "Password"<br>********.Documents.Open ("E:\Graph Book.rep")<br>********<br>********<SPAN style="color:#00007F">With</SPAN> .ActiveDocument<br>************.Refresh<br>********<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>****<br>****<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
This opens BO & the required file, and refreshes it. So far, so good.
My problem lies with the next step, of getting the data from the refreshed BO report into Excel.
I found this code:
<font face=Courier New>****<SPAN style="color:#00007F">With</SPAN> .ActiveDocument<br>********.Refresh<br>********i = 1<br>********<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> rpt <SPAN style="color:#00007F">In</SPAN> .Reports<br>****************rpt.Activate<br>****************BOApp.CmdBars(2).Controls("&Edit").Controls(20).Execute<br>****************Sheets(i).Range("A1").PasteSpecial Paste:=xlPasteValues<br>************i = i + 1<br>********<SPAN style="color:#00007F">Next</SPAN><br>****<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN></FONT>
which should select all / copy all in the BO report, and then paste it into Excel. I can't get it to work. I receive the error "Paste Special method of range class failed" at the "Sheets(i).Range("A1").PasteSpecial Paste:=xlPasteValues" line.
I found references to "adding BO to the Excel library", but I couldn't find how to do this and I'm not sure if this is the cause.
Could anyone help please?
Ian