[Solved] Finding Frames and there Properties

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
wmorrison1967
Posts: 4
Joined: Fri Dec 08, 2017 6:55 pm

[Solved] Finding Frames and there Properties

Post by wmorrison1967 »

Hello,
I need a little help. I would like to find all the frames in a document and retrieve their properties. The properties I would like to get is the size so that I can insert on image to match the frame. I am know how to find a frame if I know the name. But the document that I will be processing will have frames but I will not know the names. The using VB to do the work.

Regards,
Will
Last edited by Hagar Delest on Sun Dec 10, 2017 11:11 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1 on windows 10
FJCC
Moderator
Posts: 9278
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Finding Frames and there Properties

Post by FJCC »

Here are three ways to iterate over the frames in a document

Code: Select all

oFrames = ThisComponent.TextFrames
'By Index
Cnt =oFrames.Count
For i = 0 to Cnt - 1
	Frm = oFrames.getByIndex(i)
	print Frm.Name, Frm.Size.Height, Frm.Size.Width
next i
'By Name
aNames = oFrames.ElementNames
For i = 0 to UBound(aNames)
	Frm = oFrames.getByName(aNames(i))
	print Frm.Name, Frm.Size.Height, Frm.Size.Width
next i
'Enumeration
oEnum = oFrames.createEnumeration()
While oEnum.hasMoreElements
	Frm = oEnum.nextElement()
	print Frm.Name, Frm.Size.Height, Frm.Size.Width
WEnd
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.
wmorrison1967
Posts: 4
Joined: Fri Dec 08, 2017 6:55 pm

Re: Finding Frames and there Properties

Post by wmorrison1967 »

Works great. Thanks
OpenOffice 4.1 on windows 10
Post Reply