Macro to align top my whole sheet

Hi all

I would like a macro to align top my whole Calc sheet.

Anyone knows ?

Again - “whole sheet” or “every cell of the whole sheet”? If you were doing it by hand, what tools would you use?

I would do Ctrl-A and then click on “Align Top”

Oh, no need macro - just change Default style

I’ve tried but it doesn’t seem persistent: when I close and open my csv again, it’s back to the default value (may be I should have specified that my file is a csv).

Oh, of course this should have been said. The CSV file is very simple, it cannot store formatting. See last message here

Sure but macros work on csv opened with LibreOffice.

Well, try this:

Sub AllTextToTop
Dim oCursor As Variant 
	oCursor = ThisComponent.getCurrentController().getActiveSheet().createCursor()
	oCursor.gotoEndOfUsedArea(True)
	oCursor.VertJustify = com.sun.star.table.CellVertJustify.TOP
End Sub

It doesn’t seem to work. At the same time, in Pitonyak’s tutorial, page 465, the line oCell.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER doesn’t seem to work either (“Hello” is on the right in the figure).

It is very strange. I double-checked the operation of the macro in OpenOffice 4.1.5 and LibreOffice 7.0.4

I’ve just checked again, without more success (and some other commands at the same place work).
I guess there should be no connection, but did you work on a csv file?
No connection either, but I’m on LibreOffice 6.4.6.2.
But I’m clearly not an expert, I hope I’m not missing something stupid.

About Listing 412. Center “Hello” and rotate it 30 degrees. - this is the turning effect. If you comment out the last line, then Hello will be centered.

To see the word in the middle and rotated it is better to use .CellHoriJustify.LEFT.

HelloCenter.png

But with .CellHoriJustify.RIGHT it’s even worse.

HelloRight.png

Yes, I opened the CSV file, increased the rows height to make sure all values are aligned to the bottom of the cells. Executed the macro and they all jumped to the top edge of the cells.

OK I got this one

OK. My LibreOffice had a strange behavior. My customized keys were no more customized. Then the window disappeared but not its tab on Ubuntu. I closed, reopened and then it worked. Sorry to have made you lose your time and thanks.