[Solved] Enable and Disable Events & Updates in Status Bar

Creating a macro - Writing a Script - Using the API

[Solved] Enable and Disable Events & Updates in Status Bar

Postby Dheeraj » Sun Jul 12, 2020 8:34 am

I have a macro. I want that before executing macro events and status bar updates should be disabled so that macro could be speed-up. Then enable these when macro is complete. We can easily do this in VBA by following code. But I dont know how to do ths in libreoffice/openoffice basic. Any help will be greatly appreciated.

VBA Code:
Application.DisplayStatusBar = False
Application.EnableEvents = False
'macro code
Application.EnableEvents = True
Application. DisplayStatusBar = True

I want to do the same in libreoffice/openoffice Basic. But unable to find the code for it. Can anyone help?
Last edited by Dheeraj on Fri Jul 17, 2020 8:14 am, edited 1 time in total.
Openoffice 4.1
Windows 10
Dheeraj
 
Posts: 11
Joined: Sun Jun 14, 2020 12:46 pm

Re: Enable and Disable Events as well as Updates in Status B

Postby Zizi64 » Sun Jul 12, 2020 8:42 am

Tibor Kovacs, Hungary; LO6.1.6, 6.4.7 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.1.1;AOO4.1.9
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 9887
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Enable and Disable Events as well as Updates in Status B

Postby JeJe » Sun Jul 12, 2020 10:52 am

Code: Select all   Expand viewCollapse view

Sub YourSubName
Thiscomponent.lockcontrollers
on error goto hr 'to make sure don't get left in a locked state
'your code here

hr:
Thiscomponent.unlockcontrollers
End Sub
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1568
Joined: Wed Mar 09, 2016 2:40 pm

Re: Enable and Disable Events as well as Updates in Status B

Postby Dheeraj » Sun Jul 12, 2020 2:10 pm

Thanks for Replying Zizi64 and JeJe.......
I got the answer of 1st Problem from your replys:
Problem 1 Solution:
VBA:
Application.DisplayStatusBar = False
Application. DisplayStatusBar = True
Libreoffice Basic:
ThisComponent.CurrentController.Frame.LayoutManager.HideElement( "private:resource/statusbar/statusbar" )
ThisComponent.CurrentController.Frame.LayoutManager.ShowElement( "private:resource/statusbar/statusbar" )

Problem 2 Solution:
VBA:
Application.EnableEvents = False
Application.EnableEvents = True
Libreoffice Basic:
I learnt that there is no need of enabling and disabling Events in Libreoffice as Libreoffice automatically disables events while executing any macro. However this is not the case with the VBA. I made a same program in both VBA and Libreoffice Basic and tested it. Locking and unlocking controllers does not make any difference as Libreoffice does not excecute events at all.

Problem 1 is solved.
Please Let me know if I am wrong about what I have learnt regarding Problem 2. Thanks in advanced.
Openoffice 4.1
Windows 10
Dheeraj
 
Posts: 11
Joined: Sun Jun 14, 2020 12:46 pm

Re: Enable and Disable Events as well as Updates in Status B

Postby JeJe » Sun Jul 12, 2020 4:22 pm

I assumed lockcontrollers would stop status bar updates as well as the component window updates without hiding the status bar but didn't test that. You can also use the status bar to show a progress indicator for your running code:

https://www.openoffice.org/api/docs/com ... cator.html

I suggest you test your code while running with the events you're worried about to see if there are problems.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1568
Joined: Wed Mar 09, 2016 2:40 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 10 guests