Revision history [back]

hide columns via code

I would like to hide columns on click with a push button. I have set this up with a macro, but get inconsistent results. My current macro, keeps hiding the same number of columns on multiple clicks.

I would like to code it like VBA to hide a range of columns. Like D to F or AF to AH.

I know how to set this up in Excel, not in libre calc.

This is what I have so far....

sub Main
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:HideColumn", "", 0, Array())
end sub


Thanks,

D

hide columns via code

I would like to hide columns on click with a push button. I have set this up with a macro, but get inconsistent results. My current macro, keeps hiding the same number of columns on multiple clicks.

I would like to code it like VBA to hide a range of columns. Like D to F or AF to AH.

I know how to set this up in Excel, not in libre calc.

This is what I have so far....

sub Main
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:HideColumn", "", 0, Array())
end sub


Thanks,

D

Update: 3/10/2019 This is what worked for me.....

Sub Main
dim document   as object
dim theRange as object
document   = ThisComponent.CurrentController.Frame
theRange = ThisComponent.Sheets.GetByIndex(0).getCellRangeByName("G1:J1")
theRange.Columns.IsVisible = False
End Sub


I just change the G1:J1 for other groups of columns, I change the False to True to show them again.

Thanks for all the help!