Macro command to have visibility of screen off while macro runs, so screen stops following macros actions

Macro works ok, but looks sloppy on screen during macro actions.

Instead of trying to lock the view and to unlock it later, you may switch visibility off first and on again at he end of the action.

Sub Demo
theFrame = ThisComponent.CurrentController.Frame
theFrame.ComponentWindow.Visible = False 
'Or: theFrame.ContainerWindow.Visible = False
MsgBox "You can't see the frame now."
theFrame.ComponentWindow.Visible = True  
'Or: theFrame.ContainerWindow.Visible = True  '(respectively)
MsgBox "But now I'm back."
End Sub

(Editing:)
The original subject was about locking the view. It was slightly edited in hindsight.

Thanks @Lupp!! It worked great. Looks clean now! I reworded my question to your work “visibility”, and took out “lock”, if it looks OK to you I’ll close it, or will tomorrow. Again thanks.

Closing answers is offered as one way here. IMO it isn’t very helpful. If you want to mark your question solved because you accepted one of the answers, click the checkmark at its left.
(In specific cases changing the question/subject subseqent to the answers may leave a contibutor a bit unhappy as he may seem to not have read the question thoroughly enough.)

Accepting an answer is shown with images at How do I mark the best answer to my question on this site? - #13 by manj_k.

Thanks! I hope it’s OK now, still, mystical, a guess as I go. Kind of makes me gun shy, that I may mess up, again. But site has been very helpful, thanks for your time, and watching those like me! :slight_smile: I’ll be back.

This becomes very important with intensive macros. Use ThisComponent.lockControllers() and then ThisComponent.unlockControllers() at the end.

Thanks @paul1149. I put lock just below sub name, and unlock just before end sub. Not sure what I am doing wrong! It run, but did not lock screen. Checked to see if I put it in right sub, did. I don’t do much more than ask LO to record a macro, do I need to dim, as object?? LO 5.3.4.2, Windows 10.

Hmmm. I just realized your query concerns calc, whereas my answer was for writer. It’s not working here either in calc. Sorry about that. There should be something similar for calc, but I don’t know what it is. My source was Andew’s book at http://www.pitonyak.org/oo.php.

Thanks. I will save your above commands for writer.

@paul1149 I just now noticed the cross in your picture. I, have a Lion, Lamb & Cross! My question was on a spreadsheet that I use for Bible reading, study. Built with my grand kids in mind. You may find it interesting, I hope useful. Do what you like with it. https://goo.gl/pAS4yd

Hi Mark. That’s a real nice piece of work. Thanks. :slight_smile:

Thanks, means a lot, seeing I know no one personally who likes or uses spreadsheets and you being so active and helpful here on this site. Let me know if ya find something that would make it better. Pass it on to those who like to read the Bible.

The link above to Bible reading plan and sorting verses, did not have buttons working on it! I just learned how to have macros to run from the book! Here it is again, working. http://bit.ly/2GxTZFF