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

Creating a macro - Writing a Script - Using the API

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

Postby id_james2000 » Wed May 07, 2014 7:24 am

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
id_james2000
 
Posts: 4
Joined: Tue May 06, 2014 3:38 pm

Re: How to get the Page Number of Text Fields

Postby FJCC » Wed May 07, 2014 1:07 pm

The only way I know of to get a page location is with the ViewCursor. I would use code like this
Code: Select all   Expand viewCollapse view
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
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7230
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to get the Page Number of Text Fields

Postby id_james2000 » Fri May 09, 2014 9:28 am

Dear FJCC,

Thank you so much. Your code solved my problem.

Great Help. :D

James
OpenOffice 3.1 on Windows Vista
id_james2000
 
Posts: 4
Joined: Tue May 06, 2014 3:38 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests