[Solved] How to get the Page Number of Text Fields

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
id_james2000
Posts: 4
Joined: Tue May 06, 2014 3:38 pm

[Solved] How to get the Page Number of Text Fields

Post by id_james2000 »

Hi friends,

I want to get the Page Number of the DependentTextFields.

I haven given below my code.


oFieldMaster = ThisComponent.TextFieldMasters
oField = oFieldMaster.getByName("com.sun.star.text.fieldmaster.SetExpression.Left_Guideword_L")
stDTF = oField.DependentTextFields


stDFT has array of Text fields. I want to get the Page Number of each field.

Thank you.

James
Last edited by id_james2000 on Fri May 09, 2014 9:29 am, edited 2 times in total.
OpenOffice 3.1 on Windows Vista
FJCC
Moderator
Posts: 9231
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to get the Page Number of Text Fields

Post by FJCC »

The only way I know of to get a page location is with the ViewCursor. I would use code like this

Code: Select all

oVC = ThisComponent.CurrentController.ViewCursor
oTextFields = ThisComponent.TextFields
FieldEnum = oTextFields.createEnumeration()
While FieldEnum.hasMoreElements
	oField = FieldEnum.nextElement()
	Anch = oField.Anchor
	oVC.gotoRange(Anch.Start, False)
	Print oVC.Page
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.
id_james2000
Posts: 4
Joined: Tue May 06, 2014 3:38 pm

Re: How to get the Page Number of Text Fields

Post by id_james2000 »

Dear FJCC,

Thank you so much. Your code solved my problem.

Great Help. :D

James
OpenOffice 3.1 on Windows Vista
Post Reply