6 messages in org.openoffice.fr.progRe: [prog] Methode au comportement bi...
FromSent OnAttachments
PhilippeApr 27, 2006 2:31 pm 
Francois GattoApr 27, 2006 11:11 pm 
PhilippeApr 28, 2006 10:40 am 
PhilippeApr 28, 2006 12:48 pm 
Laurent GodardApr 29, 2006 12:51 am 
PhilippeApr 29, 2006 1:17 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] Methode au comportement bizarreActions...
From:Francois Gatto (oo@volcar.org)
Date:Apr 27, 2006 11:11:35 pm
List:org.openoffice.fr.prog

Bonjour,

Philippe a écrit :

Bonsoir,

lorsque j'utilise le code suivant : msgbox oCalendrierDocs.NumberFormats.queryKey("JJ MM AA",suPatois,false)

j'obtiens -1 comme affichage, alors que le format fait bien parti de la liste énumérée par la méthode queryKeys. Je n'arrive pas à récupérer la clé du format. Une piste ou une idée ?

Une idée ! Sub TestQueryKey

Dim oDoc As Object Dim oSheet As Object Dim oCell As Object Dim oFormats As Object Dim oFormat As Object Dim sFormat As String Dim NumFormat As Long Dim oFrenchLocale As New com.sun.star.lang.Locale

With oFrenchLocale .Country = "FR" .Language = "fr" End With

oDoc = ThisComponent oFormats = oDoc.getNumberFormats() oSheet = oDoc.getSheets().getByIndex ( 0 ) 'Feuille1 oCell = oSheet.getCellByPosition ( 1, 5 ) 'B6

oCell.setFormula ( "=TODAY()" ) sFormat = "DD/MM/YYYY" 'sFormat = "NNN J MMMM AAAA"

'queryKey( aFormat as string, nLocale as struct, bScan as boolean ) AS long NumFormat = oFormats().queryKey( sFormat, oFrenchLocale, TRUE)

'définition du nouveau format 'sFormat = "NNN J MMMM AAAA" sFormat = "JJ MM AAAA" 'sFormat = "JJ MMM AAAA"

If NumFormat = -1 Then 'addNew ( aFormat as string, nLocale as struct ) AS long NumFormat = oFormats().addNew ( sFormat, oFrenchLocale ) End If

oFormat = oFormats.getByKey(NumFormat) xray oFormat 'le format de la cellule est mise à jour oCell.NumberFormat = NumFormat

MsgBox oCell.NumberFormat & Chr(10) & oFormat.Type & Chr(10) & oFormat.FormatString

End Sub