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:Philippe (plap@nordnet.fr)
Date:Apr 28, 2006 10:40:24 am
List:org.openoffice.fr.prog

Bonsoir François

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)

Pourquoi affectes-tu un format anglais, avec une locale french ? Si je comprends bien queryKey renvoie -1 si le format n'existe pas ? Ce que j'avais vu dans le livre de Bernard et Laurent. Mais ce que je ne comprends pas c'est pourquoi après avoir demandé les formats par _queryKeys_, j'obtiens un -1 sur un format pourtant bien existant A moins que la méthode queryKey ne manipule pas la même source de données que queryKeys . Ce qui explique pourquoi tu ajoutes le format ci-après. ???

'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