How to find Sheet index in my sheets

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
zenira
Posts: 88
Joined: Sun May 11, 2014 11:24 am

How to find Sheet index in my sheets

Post by zenira »

hi friends
I have to find sheet index (its name is "my sheet 1")
Dim Doc As Object
Dim Sheet As Object
Doc = ThisComponent
Sheet = Doc.Sheets.getByName("my sheet 1")
dim i as integer
i=Sheet.getIndex REM this not work


thank you for your help
LibreOffice 4.1.0.4 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to find Sheet index in my sheets

Post by Villeroy »

A sheet has range properties.
addr = oSheet.getRangeAddress()
sh = addr.Sheet (0 based)
sc = addr.StartColumn (always 0 for a sheet)
sr = addr.StartRow (always 0 for a sheet)
ec = addr.EndColumn (=columns.count -1)
ec = addr.EndRow (=rows.count -1)

Directly on the sheet:
=SHEET(INDIRECT("SheetName"&".A1"))
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
zenira
Posts: 88
Joined: Sun May 11, 2014 11:24 am

Re: How to find Sheet index in my sheets

Post by zenira »

Villeroy wrote:A sheet has range properties.
addr = oSheet.getRangeAddress()
sh = addr.Sheet (0 based)
sc = addr.StartColumn (always 0 for a sheet)
sr = addr.StartRow (always 0 for a sheet)
ec = addr.EndColumn (=columns.count -1)
ec = addr.EndRow (=rows.count -1)

Directly on the sheet:
=SHEET(INDIRECT("SheetName"&".A1"))
They are about Cells and Ranges.
LibreOffice 4.1.0.4 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to find Sheet index in my sheets

Post by Villeroy »

A sheet can be seen as a huge cell range because http://www.openoffice.org/api/docs/comm ... sheet.html includes service SheetCellRange which implements interface XCellRangeAddressable having method getRangeAddress().
[Tutorial] Introduction into object inspection with MRI
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
Post Reply