Ask Your Question
0

how to disable screen updating while running a macro in Calc?

asked 2018-03-27 21:53:06 +0200

beampoweramp gravatar image

updated 2018-03-28 01:47:49 +0200

I'm running a macro that parses data out of a rather lengthy spreadsheet. Is there a way to disable the screen from updating until the macro is finished? This might help speed up the macro.

Examples shown elsewhere say to use

thisComponent.lockControllers
thisComponent.enableAutomaticCalculation(false)

but this does not work on my LibreOffice Version: 6.0.2.1 (x64).

rem ----------------------------------------------------------------------
sub CollectTimeThree
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
dim i
dim args1(0) as new com.sun.star.beans.PropertyValue

rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem disable screen updating and disable recalculation
thisComponent.lockControllers
thisComponent.enableAutomaticCalculation(false)

For i = 1 To 150

rem bunch of code here

Next i

rem enable screen updating and enable recalculation
thisComponent.enableAutomaticCalculation(true)
thisComponent.calculateAll
thisComponent.unlockControllers

end sub
edit retag flag offensive close merge delete

Comments

Have you tried following the sample to the letter, creating a new variable like oDoc=thisComponent, and then doing lockControllers/unlockControllers on that variable?

When you are new to something, first please follow the advises closely.

Mike Kaganski gravatar imageMike Kaganski ( 2018-03-28 06:06:10 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2020-10-17 11:06:09 +0200

Mike421 gravatar image

updated 2020-10-17 11:07:30 +0200

I used the following code, and it worked fine:

Dim Doc As Object

Doc = ThisComponent

doc.lockcontrollers

edit flag offensive delete link more

Comments

See https://api.libreoffice.org/docs/idl/....
And regard:

The calls to XModel::lockControllers() and XModel::unlockControllers() may be nested and even overlapping, but they must be in pairs. While there is at least one lock remaining, some notifications for display updates are not broadcasted.

Lupp gravatar imageLupp ( 2020-10-17 13:19:32 +0200 )edit
0

answered 2018-03-27 22:03:52 +0200

edit flag offensive delete link more

Comments

outside my for loop, I added this code:

rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
document.lockController()
document.addActionLock()

is getting me an error:

BASIC runtime error.
Property or method not found: lockController.
beampoweramp gravatar imagebeampoweramp ( 2018-03-28 00:12:14 +0200 )edit

Sigh, reading is hard.

The first solution returned by the search above tells about

myDoc = ThisComponent
myDoc.lockControllers()

(see s at the end of lockControllers), but not about ThisComponent.CurrentController.Frame.lockController()

Mike Kaganski gravatar imageMike Kaganski ( 2018-03-28 00:19:35 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-03-27 21:53:06 +0200

Seen: 1,316 times

Last updated: Oct 17