4 messages in org.openoffice.fr.progRe: [prog] Recherche dans writer avec...
FromSent OnAttachments
Geoffroy MagnanMar 19, 2004 8:01 am 
Alain NowakMar 19, 2004 8:42 am 
Geoffroy MagnanApr 5, 2004 8:17 am 
Bernard MarcellyApr 5, 2004 9:02 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [prog] Recherche dans writer avec une variableActions...
From:Bernard Marcelly (marc@club-internet.fr)
Date:Apr 5, 2004 9:02:12 am
List:org.openoffice.fr.prog

At 17:18 2004-04-05, Geoffroy Magnan wrote:

Oups, la réponse m'avait échappé !

Le 19/03/2004 17:42 , Alain Nowak a écrit :

Bonjour, Je suppose que tu utilise un SearchDescriptor. Tu a bien mis : .SearchStyles = true ? Oui ! Et quand tu affiche le contenu de ta variable, il y a bien ce qu'il faut ?

Oui !

Je stocke donc le style courant dans une variable (Style_deb), puis j'essaie de faire la recherche en utilisant : .SearchString = Style_deb, mais cela ne donne aucun résultat.

Si je remplace Style_deb par "Titre 1", la macro fonctionne...

Ton exemple montre que le problème vient des styles prédéfinis. Un style comme Titre 1 a un nom interne en anglais : Heading 1 Quand on récupère le style courant, on obtient le nom anglais, mais probablement que pour rechercher il faut le nom localisé... Pour un nom de style créé par l'utilisateur ça devrait marcher car évidemment il n'y a pas deux noms.

Pour récupérer le nom localisé d'un style prédéfini utiliser cette fonction de traduction :

Function tradStyleParagr(leDoc As Object, nomStyle As String) As String Dim desStyles As Object, unStyle As Object

on Error Goto pbStyle desStyles = leDoc.StyleFamilies.getByName("ParagraphStyles") unStyle = desStyles.getByName(nomStyle) tradStyleParagr = unStyle.DisplayName On Error Goto 0 exit function

pbStyle: On Error Goto 0 tradStyleParagr = "????" End Function

----------- exemple d'utilisation :

Sub Main dim s As String, doc As Object

doc = thisComponent s = inputbox("nom anglais du style") MsgBox(tradStyleParagr(doc, s)) End Sub

Tester avec les noms anglais suivants (respecter la casse) : Footer Marginalia Salutation

Salutations... Bernard