Sans le code, c'est difficile de comprendre ce qui se passe, surtout que j'ai une macro du même genre qui marche très bien.
 Cordialement

Marceau

Bruno ABRATANSKI a écrit :
 En fait j'ai déclaré :

Postrouve comme un objet

Lors de : postrouve = mondocument.findfirst(jecherche) ==> pas de pb
Je teste postrouve dans ma boucle : si postrouve = null sortir ==> pas de pb
Par contre, dès que je fais : postrouve =
mondocument.findnext(postrouve.end,jecherche) ==> PB

Il me dit que le type de ma variable n'est pas compatible, c'est ça que je
ne comprends pas alors que pour le findfirst il n'y a pas de pb !


-----Message d'origine-----
De : Marceau GUIHARD [mailto:[EMAIL PROTECTED] Envoyé : lundi 13 novembre 2006 15:20
À : prog@fr.openoffice.org
Objet : Re: [prog] Pb Recherche Remplace dans Writer

Bonjour

1 ) findfirst et findnext retournent un textrange ou null mais pas un
booléen : extrait du devGuide 7.3.3 Search and replace The methods
findFirst() and findNext() return a com.sun.star.uno.XInterface pointing to
an object that contains the found item. If the search is not successful, a
null reference to an XInterface is returned, that is, if you try to query
other interfaces from it, null is returned.

et dans l'IDL :
findFirst
::com::sun::star::uno::XInterface
findFirst(      [in] XSearchDescriptor   xDesc );
Description
     searches the contained texts for the next occurrence of whatever is
specified.
Returns
     the position within the component, e.g. a
::com::sun::star::text::XTextRange which determines the found elements.

2 ) il ne me semble pas nécessaire de re-créer un curseur (qui est un
textrange) sur le textrange postrouve, autant se servir du textrange
lui-même pour faire la modif:
postrouve.string = "£"

3 ) j'aurais plutôt écris findnext(postrouve.end,jecherche)

Mais, bien sûr, les points 2 et 3 n'engagent que moi ;-)

Cordialement

Marceau

Bruno ABRATANSKI a écrit :
Mettre un false à la place de Null ?

Ça empeche pas l'erreur lors du findnext non ?
-----Message d'origine-----
De : Manuel NAUDIN [mailto:[EMAIL PROTECTED] Envoyé : lundi 13 novembre 2006 12:04 À : prog@fr.openoffice.org Objet : Re: [prog] Pb Recherche Remplace dans Writer

Le 13/11/06, Bruno ABRATANSKI <[EMAIL PROTECTED]> a écrit :

 Bonjour,

Bonjour,



Pb lors d'un recherche remplace je fais :

postrouve = mondocument.findfirst(jecherche) boucle
    si postrouve = null sortir
    curseur = mondocument.text.cretaetextcursorbyrange(postrouve)
    curseur.string = "£"

     postrouve = mondocument.findnext(postrouve,jecherche)
fin

Lors du findnext j'ai une erreur comme quoi le type de la variable postrouve est incompatible alors que le findfirst a bien fonctionné ??



moi j'aurais fait :
<code>
 postrouve = mondocument.findfirst(jecherche) boucle
    si postrouve = false sortir
    curseur = mondocument.text.cretaetextcursorbyrange(postrouve)
    curseur.string = "£"

postrouve = mondocument.findnext(postrouve, ,jecherche) fin </code>

 *Bruno ABRATANSKI**

*


Manuel

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




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

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




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

Répondre à