Is it possible to hide grid on a specific sheet by macro?
This also works without a macro.
Simply turn off the Grid Lines (View → View Grid Lines
) on the sheet.
Add the following two functions to the text from that message:
Sub SetSheetGridVisible(Byval oSheet as Object, Byval bVisible as Boolean)
Dim oDoc as Object, oEvent as Object
oDoc = oSheet.DrawPage.Forms.Parent
oEvent = GetFeatureState(oDoc, "ToggleSheetGrid")
If Not (oEvent Is Nothing) Then
If oEvent.State <> bVisible Then
oEvent.Source.Dispatch oEvent.FeatureUrl, Array()
End If
End If
End Sub
' Hide the grid on the first sheet of the current document.
Sub TestSetSheetGridVisible()
SetSheetGridVisible ThisComponent.Sheets(0), False
End Sub
Thank you very much! This is just what I needed…
Using the DispatchHelper service not preferable. Thanks anyway!
because of ?
Only affects the active sheet and using of standard UNO interfaces makes code more robust
- 10 Extrapoints to @sokol92 in the Category »hide-dispatcher-code-the-creative-way«
on the other side I dont see any advantage compared to the suggestion already made by @PKG
Hello, @karolus !
We create software for displaying corporate systems information in LibreOffice using macros. So we need to be able to take into account the wishes of users. “Remove the Grid from the sheet” is a common request.
Yes, but it can be done by shortcut Alt a e (on a german GUI) so what?
Users could interactively do many of the things we do for them with macros: format cells, set up autofilters, create conditional formatting rules, enter formulas, build pivot tables…
Hello everyone! Creating a wrapper over the GUI is, as I understand it, a forced step for LO developers until the corresponding API functions are implemented. Of course, this can be used, but then what is the point of all the other LO Basic functionality? And of course, everything that can be done with macros can be done manually.
OK guys, thanks to all!
The following code, recorded by MRI, fails silently:
Sub Snippet
Dim oObj1 As Variant
oObj1 = ThisComponent.createInstance("com.sun.star.sheet.DocumentSettings")
oObj1.ShowGrid = False
End Sub
Hello @Villeroy !
What do you mean? The code you provided works for me without errors.
These settings apply to subsequently created views and are saved with the document