Miguel Quirós wrote:

Hello. I am not sure if I am sending this message to the proper place.
In this case, I would be grateful for a reply telling me which this
proper place may be.
Anthony already indicated the best place to ask this question...

I wrote a macro for OpenOffice 1.1.4 that used a sentence like the
following:
 encontrado = dispatcher.executeDispatch(document,
".uno:ExecuteSearch", "", 0, busqueda())
to perform a text search in a document and get a boolean value (stored
in the boolean variable encontrado) to check whether the search was
successful or not.
You are using the dispatcher, which works, but is more likely to change than using regular API calls.

Could anyone tell me which kind of value (if any!) is returned by this
procedure in OpenOffice 2.0? How can I get now the boolean value I used
to get in Open Office 1.1?
I do not believe that this is really the best way to do this. When I want to know what is returned, I usually end up looking at hte source code, which is a very difficult thing to do (so I recommend against it). If you obtained the macro using the macro recorder, perhaps you can record the macro again. Otherwise, perhaps you can modify an existing API example that is less likely to change. If all that you want to do is to see if some text exists, then the following might work for you.

 Dim vDescriptor, vFound
 ' Create a descriptor from a searchable document.
 vDescriptor = ThisComponent.createSearchDescriptor()
 ' Set the text for which to search and other
' http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchDescriptor.html
 With vDescriptor
   .SearchString = "hello"
   ' These all default to false so you can comment them if you do
   ' not want them...
   .SearchWords = true
   .SearchCaseSensitive = False
 End With
 ' Find the first one
 vFound = ThisComponent.findFirst(vDescriptor)
 ' At this point, all you seemed to want to know was if it existed or not
 ' Note, however, that the search as shown is from the START of the
 ' document.
 If IsNull(vFound) Then
   Print "The text did NOT exist"
 Else
   Print "The text did exist and was found"
 End If

If you set the variable "cursor" to something first, you should be able to use "ThisComponent.findNext(cursor, vDescriptor)" to start from a different location than the start.

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to