[Solved] Getting Cell address of the current selection

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
heshfer
Posts: 25
Joined: Tue Apr 07, 2015 1:20 pm
Location: Sri Lanka

[Solved] Getting Cell address of the current selection

Post by heshfer »

Hi,

Can anyone help me with a code to get the address of the the first and last cell of the selected cells.

Note:
Selected cells can have empty cells.
Last edited by Hagar Delest on Thu May 14, 2015 4:29 pm, edited 1 time in total.
Reason: tagged [Solved].
Open Office 4.1.1
Windows 7
User avatar
Zizi64
Volunteer
Posts: 11489
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Getting Cell address of the current selection

Post by Zizi64 »

Code: Select all

Sub GetRangeName
	
oRange = ThisComponent.getCurrentSelection()
print oRange.AbsoluteName

end sub   
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11489
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Getting Cell address of the current selection

Post by Zizi64 »

or:

Code: Select all

Sub Getcellname
	oRange = ThisComponent.getCurrentSelection()
	print oRange.AbsoluteName
	
	oCellTopLeft = oRange.getCellByPosition(0, 0)
	print oCellTopLeft.AbsoluteName
	
	lRows = oRange.getRows().getCount()
	Print lRows
	lCols    = oRange.getColumns().getCount()
	print lCols
	
	
	oCellRightBottom  = oRange.getCellByPosition(lCols-1, lRows-1) 
	print oCellRightBottom.AbsoluteName
end sub  
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
heshfer
Posts: 25
Joined: Tue Apr 07, 2015 1:20 pm
Location: Sri Lanka

[Solved] Getting Cell address of the current selection

Post by heshfer »

Dear Sir,

It worked. Thank you for spending your time for me.
Open Office 4.1.1
Windows 7
Post Reply