BOB: Business Objects Board
Not endorsed by or affiliated with SAP

Register | Login 

Follow BOB on Twitter! 
Follow BOB on Twitter! (Opens a new window)  

General Notice: BOB is going to retire...please see details here.
General Notice: No events within the next 45 days.

Run VBA macro when opening a report or it's refreshed


 
Search this topic... | Search SDK (VBA/ASP/JSP)... | Search Box
Register or Login to Post    Forum Index -> SDK (VBA/ASP/JSP)  Previous TopicPrint TopicNext Topic
Author Message
juagar
Forum Member
Forum Member



Joined: 31 Jan 2018

Posts: 5



PostPosted: Wed Jan 30, 2019 6:49 am 
Post subject: Run VBA macro when opening a report or it's refreshed

In Access if I create a macro called "autoexec", it executes when I open that Access database. Does anyone know if there is something similar in Business object macros that allows me to execute a macro when I open the report or when I refresh it?

I know that I can configure the report to refresh it automaticaly when I open it (clicking in a checkbox in Tools > Options > Save) but I don't know how to execute a macro that I have created inside the report to run it when I open the report or when I have refreshed it.

In my company, we are running Business Objects 6.1...Yes it's obsolete, but it's what we have.

Thanks in advance
Back to top
Mark P
Forum Devotee
Forum Devotee



Joined: 03 Feb 2003
ASUG Icon
Posts: 11455
Location: Manchester, UK


flag
PostPosted: Wed Jan 30, 2019 10:14 am 
Post subject: Re: Run VBA macro when opening a report or it's refreshed

Obsolete is a very polite word for 6.1 icon_lol.gif

Have a look through this:
https://wiki.scn.sap.com/wiki/display/BOBJ/Getting+Started+with+Desktop+Intelligence+VBA+macros

That's the only resource I could find.

_________________
Current version I'm using: 4.1 SP3 over Oracle. Well versed in SQL Server too, including SSIS

______________________________________
Prior versions used: BO3,4,5,6.5,XIr2,XI3, 4.1 - yes, I have been using BO since 1996!
Back to top
SuKA
Forum Member
Forum Member



Joined: 20 Oct 2018

Posts: 18



PostPosted: Wed Jan 30, 2019 11:11 am 
Post subject: Re: Run VBA macro when opening a report or it's refreshed

Hi,

I know nothing about Business Objects 6.1.

In BOXIR2 & BO 3.1 you may use the Document_Open() event.
Back to top
juagar
Forum Member
Forum Member



Joined: 31 Jan 2018

Posts: 5



PostPosted: Wed Jan 30, 2019 12:08 pm 
Post subject: Re: Run VBA macro when opening a report or it's refreshed

Thanks SuKa for your answer.
So If I understand you well, if I create a macro called Document_Open with the following code:

Code:
Sub Document_Open()
   ThisDocument.Refresh
   ThisDocument.SaveAs("C\Result.xls")
   ThisDocument.Close
End Sub


It will execute just when I open the report, even from the command line. That's right?

I would like to launch some reports from command line and I want to save the results when they have refreshed. I think that would be the best approach if it works because I don't have access BCA to do something similar.
Back to top
juagar
Forum Member
Forum Member



Joined: 31 Jan 2018

Posts: 5



PostPosted: Thu Jan 31, 2019 10:50 am 
Post subject: Re: Run VBA macro when opening a report or it's refreshed

I have tried the code I wrote in my last post and it didn't work when it was inside a module. If I select the document, I see there are some events I can use. I select for example AfterRefresh and I write the following code and I have an error:

Code:
Private Sub Document_AfterRefresh()

    ThisDocument.SaveAs ("C:\Result.xls")
   
End Sub


Code:
Runtime error 10 - This funtion cannot be executed at this time


I have tried saving the result in .txt and I get the same error.
If I execute the code directly from de VBA editor, it works, it saves the document in xls or txt without problem, but it doesn't work when is launched by the event.

Does anyone know why I get that runtime error?
Thanks in advance!
Back to top
SuKA
Forum Member
Forum Member



Joined: 20 Oct 2018

Posts: 18



PostPosted: Fri Feb 01, 2019 4:23 am 
Post subject: Re: Run VBA macro when opening a report or it's refreshed

Are your code in the ThisDocument class? In a simple standard VBA module it will not be executed on open event.
From your next post I see you have found the Document_AfterRefresh event. At the same location you shold see the Open event too. If you click on it, a new empty "Private Sub Document_AfterRefresh()" procedure will be placed into the VBE editor. Place your code there.
[/img]
Back to top
SuKA
Forum Member
Forum Member



Joined: 20 Oct 2018

Posts: 18



PostPosted: Fri Feb 01, 2019 4:32 am 
Post subject: Re: Run VBA macro when opening a report or it's refreshed

Sorry, you should get an empty "Private Sub Document_Open()" proc, of course.
Back to top
Display posts from previous:   
Register or Login to Post    Forum Index -> SDK (VBA/ASP/JSP)  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 5 Hours
 
Jump to:  

Index | About | FAQ | RAG | Privacy | Search |  Register |  Login 

Get community updates via Twitter:

Not endorsed by or affiliated with SAP
Powered by phpBB © phpBB Group
Generated in 0.0285 seconds using 18 queries. (SQL 0.0032 Parse 0.0009 Other 0.0244)
CCBot/2.0 (https://commoncrawl.org/faq/)
Hosted by ForumTopics.com | Terms of Service
phpBB Customizations by the phpBBDoctor.com
Shameless plug for MomentsOfLight.com Moments of Light Logo