Select shape by name

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ze_luis
Posts: 4
Joined: Tue Dec 16, 2014 3:50 am

Select shape by name

Post by ze_luis »

Hello, I'm trying to learn a bit of OObasic.
So far, I didn't find anything, even in this forum.
Does anyone have a clue how to select one shape by name in calc?
Thanks for any help.
broffice 3.2 on linux at work
libreoffice 4.3 on windows at home
FJCC
Moderator
Posts: 9550
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: macro to select shape by name

Post by FJCC »

The Drawpage of a Calc sheet doesn't have a getByName() method. You could try iterating over all the objects and testing the name, though I don't know that all possible objects will have a Name property.

Code: Select all

oSheet = ThisComponent.Sheets.getByName("Hoja1")
oDP = oSheet.Drawpage
count = oDP.Count
For i = 0 to count - 1
	oItem = oDP.getByIndex(i)
	If oItem.Name = "TheShape" then
		print "Found it!"
	end If
next i
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.
ze_luis
Posts: 4
Joined: Tue Dec 16, 2014 3:50 am

Re: macro to select shape by name

Post by ze_luis »

Thanks for assistance.
I already did exactly the code you wrote.
As I have lots of shapes, the program became slow until find the shape and make the necessary changes.
My hope was selecting the shape in a very direct way.
Anyhow thanks again for your response.
broffice 3.2 on linux at work
libreoffice 4.3 on windows at home
Post Reply