Even newer than "a70Coupe" as far as macros are concerned.
It does work very well.
Thanks for that.
I'm amazed I managed to "make" a macro..
Can I put a spanner in the works and ask if it could name all the sheets at once, or is that a bit too much?
Thanks.
Last edited by Hagar Delest on Fri Oct 01, 2021 11:39 pm, edited 1 time in total.
Reason:Tagged [Solved].
All of the sheets can be renamed. From where do you want to get the new names?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
From C1 in each sheet.
I have 5 sheets at the moment, but more could follow, so it would have to count the number of sheets, an then rename each sheet to C1 of that sheet.
A bit of a tall order, but it would be handy.
Fitch.
Sub Rename
oSheets = ThisComponent.Sheets
Cnt = oSheets.Count
For i = 0 to Cnt - 1
oSheet = oSheets.getByIndex(i)
oCell = oSheet.getCellrangeByName("C1")
oSheet.Name = oCell.String
Next i
End Sub
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Sub rename
sheets = thisComponent.Sheets
for each sheet in sheets
cell = sheet.getCellrangeByName("C1")
sheet.Name = cell.String
next
End Sub
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM) Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4) Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
addr = ThisComponent.CurrentSelection.getRangeAddresses()
sheets = ThisComponent.getSheets()
for each a in addr
sh = sheets.getByIndex(a.Sheet)
c = sh.getCellByPosition(a.StartColumn, a.StartRow)
sh.setName(c.getString())
next
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice