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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Dheeraj
Posts: 11
Joined: Sun Jun 14, 2020 12:46 pm

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

Post by Dheeraj »

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
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Post by Zizi64 »

Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

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

Post by JeJe »

Code: Select all


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
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Dheeraj
Posts: 11
Joined: Sun Jun 14, 2020 12:46 pm

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

Post by Dheeraj »

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
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

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

Post by JeJe »

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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply