[Solved] Shape: getting its position and width

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
kaggb
Posts: 7
Joined: Tue Jan 27, 2009 9:22 pm

[Solved] Shape: getting its position and width

Post by kaggb »

could anyone tell me how given a rectangle drawn on a spreadsheet what the method is for getting its position on the document and the width of it
Last edited by Hagar Delest on Tue Jan 27, 2009 10:47 pm, edited 1 time in total.
Reason: tagged [Solved].
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: shape - positioning

Post by FJCC »

Given a single rectangle, this appears to work. If there are several, you would have to know the index of the one you are interested in.

Code: Select all

Sub Main
Dim Doc, Sheet, Rect as Object
Dim Pos as New com.sun.star.awt.Point
Dim Size as New com.sun.star.awt.Size

Doc = ThisComponent
Sheet = Doc.Sheets(0)
Rect = Sheet.DrawPage.getByIndex(0)
Pos = Rect.Position
Size = Rect.Size
Print Pos.X
Print Pos.Y
Print Size.Width 
Print Size.Height

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.
kaggb
Posts: 7
Joined: Tue Jan 27, 2009 9:22 pm

Re: shape - positioning

Post by kaggb »

perfect. thank you.
OOo 2.3.X on MS Windows Vista
Post Reply