OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Looking up an existing field in a document? (VB)

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
tthhoommaass
General User
General User


Joined: 04 May 2009
Posts: 5

PostPosted: Thu May 07, 2009 4:37 am    Post subject: Looking up an existing field in a document? (VB) Reply with quote

I have a very simple question!

How do I get a handle to a known field (say - "com.sun.star.text.TextField.User") in a odt-doc without having to loop through an entire enumeration?
Does StarOffice offer a method for this (doc. or enum.getFieldByName() -ish) or similar? I just cannot seem to find any...

Thanx a lot!

Thomas
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1145
Location: France

PostPosted: Thu May 07, 2009 10:39 am    Post subject: Reply with quote

Hi,
You can enumerate the textfields in the Writer document:
Code:
Dim enuTF As Object, aTextField As Object

enuTF = ThisComponent.TextFields.createEnumeration
Do While enuTF.hasMoreElements
  aTextField = enuTF.nextElement
  if aTextField.supportsService("com.sun.star.text.TextField.User")  then
    '  here is a user textfield
  end if
Loop

______
Bernard
Back to top
View user's profile Send private message Visit poster's website
tthhoommaass
General User
General User


Joined: 04 May 2009
Posts: 5

PostPosted: Thu May 07, 2009 11:42 pm    Post subject: Reply with quote

Thanx for your reply but...
I'm aware that I can loop thru an enumeration - That's what I want to avoid - 'cause there might be a lot of fields I need to access!
I want to 'get' the field directly by, say Name - when I already have a collection/container (enumeration/document/...) of fields or objects.
Is this really not possible?

Thanx again...
Back to top
View user's profile Send private message
hffm
General User
General User


Joined: 22 Jul 2005
Posts: 48
Location: GERARDMER FRANCE

PostPosted: Fri May 08, 2009 3:19 am    Post subject: Reply with quote

It's possible but as I already said in another post it would be great if we had an example of the document: there are several kinds of fields in oOO and I can help you if i knew what i have to search:
The "trick" in VB is to add all the fields in a collection, so you could enumerate what you need in the enumeration...
My mail is hffmnet@orange.fr
Have a nice day.
Back to top
View user's profile Send private message Visit poster's website
tthhoommaass
General User
General User


Joined: 04 May 2009
Posts: 5

PostPosted: Fri May 08, 2009 5:04 am    Post subject: Reply with quote

Ok - I guess an enumeration IS the answer then - thanx!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group