Page 1 of 1

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

Posted: Sun Jul 12, 2020 8:34 am
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?

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

Posted: Sun Jul 12, 2020 8:42 am
by Zizi64

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

Posted: Sun Jul 12, 2020 10:52 am
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

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

Posted: Sun Jul 12, 2020 2:10 pm
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.

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

Posted: Sun Jul 12, 2020 4:22 pm
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.