| View previous topic :: View next topic |
| Author |
Message |
tthhoommaass General User

Joined: 04 May 2009 Posts: 5
|
Posted: Thu May 07, 2009 4:37 am Post subject: Looking up an existing field in a document? (VB) |
|
|
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 |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1145 Location: France
|
Posted: Thu May 07, 2009 10:39 am Post subject: |
|
|
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 |
|
 |
tthhoommaass General User

Joined: 04 May 2009 Posts: 5
|
Posted: Thu May 07, 2009 11:42 pm Post subject: |
|
|
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 |
|
 |
hffm General User

Joined: 22 Jul 2005 Posts: 48 Location: GERARDMER FRANCE
|
Posted: Fri May 08, 2009 3:19 am Post subject: |
|
|
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 |
|
 |
tthhoommaass General User

Joined: 04 May 2009 Posts: 5
|
Posted: Fri May 08, 2009 5:04 am Post subject: |
|
|
| Ok - I guess an enumeration IS the answer then - thanx! |
|
| Back to top |
|
 |
|