Page 1 sur 1
[Résolu] [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 09:33
par JMB77
Bonjour à tous,
Je rencontre un problème pour formater de façon disons aléatoire des colonnes.
Aléatoire car le format de la colonne dépend du type de donnée à traiter.
Un fichier comportant des données rentre dans Calc et sur la base d'un référentiel on dit si telle ou telle donnée est numérique avec ou sans décimal, centrer, sur 3 caractéres ("030") ect.
Voici le code de formatage.
Code : Tout sélectionner
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
If valR(3) = "N" Then
args62(0).Value = "# ##0"
ElseIf valR(3) = "M" Then
args62(0).Value = "[$$-409]# ##0"
ElseIf valR(3) = "€" Then
args62(0).Value = "# ##0 [$€-40C]"
ElseIf valR(3) = "D" Then
args62(0).Value = "#0,00 [$€-40C]"
ElseIf valR(3) = "P" Then
args62(0).Value = valR(4)
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:NumberFormatValue", "", 0, args62())
Code donnée; Effacement si tout à blanc; Positionnement; Type de format; Format personnalisé; Libellé
Toto ; O ; G ; P ; 000 ; Nom en clair Toto
Titi ; ; ; N ; ; Titi & Gros Minet
Ce qui se traduit en :
la rubrique Toto aura :
comme titre de colonne : Nom en clair Toto
elle sera cadrée à Gache
elle sera sur 3 caractères avec 0 non significatif (ex : 023)
la rubrique Titi aura :
comme titre de colonne : Titi & Gros Minet
elle sera Numérique avec séparateur de millier
Or le formatage ne s'applique pas.
Pouvez-vous m'aider?
Merci d'avance.
macro_test.ots
Re: Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 09:57
par Oukcha
Bonjour,
La balise [Calc] est à placer au début de votre titre.
Merci de (re?)lire le bandeau rouge en haut de page.
Si cela n'est pas fait à votre prochain message, le sujet sera verrouillé.
Re: Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 10:04
par luky-luke
Bonjour
merci de suivre les recommandations de la modération, le bandeau rouge ne doit pas se lire en diagonale
Balise ton message correctement en écrivant [Calc] en début de titre et met les lignes de codes entre entre des balises code pour faciliter la lecture
prend exemple sur les autres fils .
Pour ton problème tu donne une valeur mais pas le nom de la propriété à laquelle celle-ci doit s'appliquer. Un exemple
Cordialement
Luke
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 10:14
par JMB77
Oups Désolé Luky-Luke.
Le code complet de cette "Fonction" est :
Code : Tout sélectionner
Sub formatcolonne(colonne, valR(), Arthur)
dim args61(0) as new com.sun.star.beans.PropertyValue
args61(0).Name = "ToPoint"
args61(0).Value = Lo_CelluleActive1
dim args62(0) as new com.sun.star.beans.PropertyValue
args62(0).Name = "NumberFormatValue"
dim args63(0) as new com.sun.star.beans.PropertyValue
args63(0).Name = "HorizontalJustification"
args63(0).Value = com.sun.star.table.CellHoriJustify.CENTER
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
Li_len = len(Lo_CelluleActive1.absolutename)
Li_pos=InStr(Lo_CelluleActive1.absolutename,".")
Ls_cellule = right(Lo_CelluleActive1.absolutename,Li_len-Li_pos)
Ls_col_traitee = mid(Ls_cellule,2,1)
Li_pos_dollar=InStr(2,Ls_cellule,"$")
Ls_cel = mid(Ls_cellule, 2, Li_pos_dollar - 2)
Ls_select = ls_cel & "2:" & ls_cel & Ll_der_lig
args61(0).Value = Ls_select
If valR(1) = "O" Then
call replace_blanc(colonne)
End If
If valR(2) = "C" Then
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:HorizontalJustification", "", 0, args63())
ElseIf valR(2) = "G" Then
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
If valR(3) = "N" Then
args62(0).Value = "# ##0"
ElseIf valR(3) = "M" Then
args62(0).Value = "[$$-409]# ##0"
ElseIf valR(3) = "€" Then
args62(0).Value = "# ##0 [$€-40C]"
ElseIf valR(3) = "D" Then
args62(0).Value = "#0,00 [$€-40C]"
ElseIf valR(3) = "P" Then
args62(0).Value = valR(4)
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:NumberFormatValue", "", 0, args62())
'--- libellé ---
If Arthur Then
Lo_CelluleActive1.string = valR(5)
End If
End Sub
C'est certainement plus clair ainsi.
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 10:21
par Hubert Lambert
Bonjour,
JMB77 a écrit :Aléatoire car le format de la colonne dépend du type de donnée à traiter.
A priori il s'agit là d'un problème de formatage conditionnel.
Si vraiment une macro est requise, il serait beaucoup plus simple de définir un style de cellule par format numérique et de l'appliquer.
Cordialement.
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 10:51
par luky-luke
Re
La valeur attendue est de type
LONG. Tu peux tester la fonction suivante si la solution d'
Hubert Lambert ne te convient pas.
Code : Tout sélectionner
Function FormatChaine(Chaine As String) As Long
Dim oDoc As Object
Dim NbrFormats As Object
Dim Loc as New com.sun.star.lang.Locale
Dim formatID As Long
oDoc = ThisComponent
Loc.Language = "fr"
Loc.Country = "FR"
NbrFormats = oDoc.NumberFormats
formatId = NbrFormats.queryKey(Chaine, Loc, False)
If formatId = -1 Then
formatId = NbrFormats.addNew(Chaine, Loc)
End If
FormatChaine = formatID
End Function
à utiliser de la façon suivante
Code : Tout sélectionner
If valR(3) = "N" Then
args62(0).Value = FormatChaine("# ##0")
Je n'ai pas fait de test mais cela devrait fonctionner
Cordialement
Luke
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 12:52
par JMB77
Merci pour vos conseils.
Hubert Lamber, effectivement une optique format conditionnel pourrait être une solution.
Mais il y a quelques 360 rubriques différentes et les fichiers en entrée ne sont pas sur un même format entre autre nombre de colonnes, rubriques utilisées.
De plus la macro Calc (OTS) génère autant de fichiers en sortie qu'il y a de fichiers à traiter. Donc nous ne somme plus dans le fichier Calc d'origine.
Le but est de mettre sous une même présentation des fichiers de données, un bandeau titre et la liste des enregistrement découpés en rubriques, des fichiers constitués différemment.
C'est la ligne titres des fichiers en entrée, qui comporte les noms de rubriques, qui sert de pilote au formatage des colonnes.
Et là encore je ne pense pas que ce soit effectuable en format conditionnel.
Luky-Luke, le code ne fonctionne pas.
Peut-être n'ai-je pas su 'l’implémenter dans le code existant.
Pour information c'est un code que je récupère, je n'en suis pas le développeur d'origine en OOO ou LOo.
J'avais écrit celui qui tournait en VBA Excel.
Donc je maitrise le principe, le fonctionnel mais pas le code LOo.
L'un des principe est d'éviter de toucher au code, c'est pourquoi si il y a de nouvelle rubriques à traiter, on les enregistre dans l'onglet Rubirque, après c'est transparent.
Hormis que là il s'avére que le format n'est pas mis en place sur les colonnes.
Par contre l'option centrage fonctionne très bien. C'est juste la partie avec ".uno:NumberFormatValue" qui ne fonctionne pas.
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 13:11
par JMB77
J'ai un peu optimisé le code.
Code : Tout sélectionner
Sub formatcolonne(colonne, valR(), Arthur)
dim args61(0) as new com.sun.star.beans.PropertyValue
args61(0).Name = "ToPoint"
args61(0).Value = Lo_CelluleActive1
dim args62(0) as new com.sun.star.beans.PropertyValue
args62(0).Name = "NumberFormatValue"
dim args63(0) as new com.sun.star.beans.PropertyValue
args63(0).Name = "HorizontalJustification"
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
Li_len = len(Lo_CelluleActive1.absolutename)
Li_pos=InStr(Lo_CelluleActive1.absolutename,".")
Ls_cellule = right(Lo_CelluleActive1.absolutename,Li_len-Li_pos)
Ls_col_traitee = mid(Ls_cellule,2,1)
Li_pos_dollar=InStr(2,Ls_cellule,"$")
Ls_cel = mid(Ls_cellule, 2, Li_pos_dollar - 2)
Ls_select = ls_cel & "2:" & ls_cel & Ll_der_lig
args61(0).Value = Ls_select
If valR(1) = "O" Then
call replace_blanc(colonne)
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
If ValR(2) <> "" Then
If valR(2) = "C" Then
args63(0).Value = com.sun.star.table.CellHoriJustify.CENTER
ElseIf valR(2) = "G" Then
args63(0).Value = com.sun.star.table.CellHoriJustify.LEFT
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:HorizontalJustification", "", 0, args63())
End If
If valR(3) = "N" Then
args62(0).Value = "# ##0"
ElseIf valR(3) = "M" Then
args62(0).Value = "[$$-409]# ##0"
ElseIf valR(3) = "€" Then
args62(0).Value = "# ##0 [$€-40C]"
ElseIf valR(3) = "D" Then
args62(0).Value = "#0,00 [$€-40C]"
ElseIf valR(3) = "P" Then
args62(0).Value = valR(4)
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:NumberFormatValue", "", 0, args62())
'--- libellé ---
If Arthur Then
Lo_CelluleActive1.string = valR(5)
End If
End Sub
Je bloque donc bien que sur cette partie spécifique
Code : Tout sélectionner
Sub formatcolonne(colonne, valR(), Arthur)
...
dim args62(0) as new com.sun.star.beans.PropertyValue
args62(0).Name = "NumberFormatValue"
...
If valR(3) = "N" Then
args62(0).Value = "# ##0"
ElseIf valR(3) = "M" Then
args62(0).Value = "[$$-409]# ##0"
ElseIf valR(3) = "€" Then
args62(0).Value = "# ##0 [$€-40C]"
ElseIf valR(3) = "D" Then
args62(0).Value = "#0,00 [$€-40C]"
ElseIf valR(3) = "P" Then
args62(0).Value = valR(4)
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:NumberFormatValue", "", 0, args62())
...
End Sub
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 13:24
par luky-luke
Re
Un exemple vaut mieux qu'un grand discours...
Code : Tout sélectionner
Sub formatcolonne(colonne, valR(), Arthur)
dim args61(0) as new com.sun.star.beans.PropertyValue
args61(0).Name = "ToPoint"
args61(0).Value = Lo_CelluleActive1
dim args62(0) as new com.sun.star.beans.PropertyValue
args62(0).Name = "NumberFormatValue"
dim args63(0) as new com.sun.star.beans.PropertyValue
args63(0).Name = "HorizontalJustification"
args63(0).Value = com.sun.star.table.CellHoriJustify.CENTER
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
Li_len = len(Lo_CelluleActive1.absolutename)
Li_pos=InStr(Lo_CelluleActive1.absolutename,".")
Ls_cellule = right(Lo_CelluleActive1.absolutename,Li_len-Li_pos)
Ls_col_traitee = mid(Ls_cellule,2,1)
Li_pos_dollar=InStr(2,Ls_cellule,"$")
Ls_cel = mid(Ls_cellule, 2, Li_pos_dollar - 2)
Ls_select = ls_cel & "2:" & ls_cel & Ll_der_lig
args61(0).Value = Ls_select
If valR(1) = "O" Then
call replace_blanc(colonne)
End If
If valR(2) = "C" Then
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:HorizontalJustification", "", 0, args63())
ElseIf valR(2) = "G" Then
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
If valR(3) = "N" Then
args62(0).Value = FormatChaine("# ##0")
ElseIf valR(3) = "M" Then
args62(0).Value = FormatChaine("[$$-409]# ##0")
ElseIf valR(3) = "€" Then
args62(0).Value = FormatChaine("# ##0 [$€-40C]")
ElseIf valR(3) = "D" Then
args62(0).Value = FormatChaine("#0,00 [$€-40C]")
ElseIf valR(3) = "P" Then
args62(0).Value = valR(4)
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:NumberFormatValue", "", 0, args62())
'--- libellé ---
If Arthur Then
Lo_CelluleActive1.string = valR(5)
End If
End Sub
Function FormatChaine(Chaine As String) As Long
Dim oDoc As Object
Dim NbrFormats As Object
Dim Loc as New com.sun.star.lang.Locale
Dim formatID As Long
oDoc = ThisComponent
Loc.Language = "fr"
Loc.Country = "FR"
NbrFormats = oDoc.NumberFormats
formatId = NbrFormats.queryKey(Chaine, Loc, False)
If formatId = -1 Then
formatId = NbrFormats.addNew(Chaine, Loc)
End If
FormatChaine = formatID
End Function
Il faut faire appel à la fonction
FormatChaine à chaque fois que tu veux appliquer une chaîne de caractère comme valeur. Si ce format n’existe pas (format utilisateur) alors il sera ajouté et mémorisé à la liste des formats de cellule du fichier d'origine et uniquement à ce fichier.
A la maison la fonction change bien le format d'une cellule. N'ayant pas l'intégralité de ton fichier avec le code difficile de savoir ou est le problème...
Cordialement
Luke
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 14:30
par JMB77
Voila le code et deux fichiers.
Faut créer un répertoire C:\Arthur sous la racine
Y mettre le fichier macro_test.ots
Y créer deux répertoires C:\Arthur\Fichiers en Entrée et C:\Arthur\Fichiers en Sortie
Placer les deux fichiers de donnés Fic1 et Fic2 dans le répertoire C:\Arthur\Fichiers en Entrée
Lancer macro_test.ots et cliquer sur le bouton Arthur, là la procédure de lecture des fichiers en entrée et génération des fichiers résultats en sortie s’exécute.
Macro :
macro_test.ots
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 14:32
par JMB77
Heu je fais comment pour les fichiers données?
Ce sont des .txt
J'essaie en ZIP
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 03 juil. 2018 16:52
par luky-luke
Re
Le problème est assez simple
. Il faut ajouter en argument dans l'appel de la fonction le nouveau fichier
(ThisComponent) que tu viens de créer.
Code : Tout sélectionner
Function FormatChaine(NewFic as Object, Chaine As String) As Long
Dim oDoc As Object
Dim NbrFormats As Object
Dim Loc as New com.sun.star.lang.Locale
Dim formatID As Long
oDoc = NewFic
Loc.Language = "fr"
Loc.Country = "FR"
NbrFormats = oDoc.NumberFormats
formatId = NbrFormats.queryKey(Chaine, Loc, False)
If formatId = -1 Then
formatId = NbrFormats.addNew(Chaine, Loc)
End If
FormatChaine = formatID
End Function
L'argument
NewFic reçut par la fonction
FormatChaine est la variable
Lo_newdossier (le nouveau fichier
sansnom1); il faut donc écrire l'appel de la fonction dans la sub
formatColonne comme suit
Code : Tout sélectionner
If valR(3) = "N" Then
args62(0).Value = FormatChaine(Lo_newdossier,"# ##0")
ElseIf valR(3) = "M" Then
args62(0).Value = FormatChaine(Lo_newdossier,"[$$-409]# ##0")
ElseIf valR(3) = "€" Then
args62(0).Value = FormatChaine(Lo_newdossier,"# ##0,00 [$€-40C]")
ElseIf valR(3) = "D" Then
args62(0).Value = FormatChaine(Lo_newdossier,"#0,00 [$€-40C]")
ElseIf valR(3) = "P" Then
args62(0).Value = valR(4)
End If
Cordialement
Luke
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 04 juil. 2018 09:17
par JMB77
Bonjour.
Merci Luky-Luke.
Je viens de tester et j'ai une erreur 423 NumberFormats, ce qui, si je ne me trompe pas, est Propriété ou méthode NumberFormats introuvable.
Et puis, pour le dernier formatage
on peut se passer la fonction FormatChaine(...).
C'est bien cela.
Petite information au fait les fichiers en entrée doivent commencer par ARTS (ARTS*.*)
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 04 juil. 2018 10:22
par luky-luke
Bonjour
JMB77 a écrit :on peut se passer la fonction FormatChaine(...).
Euh.... Oui et non, tu peux mettre directement la valeur LONG dans la macro
formatColonne Tu peux utiliser la fonction pour connaître la valeur LONG de la chaîne mais...par exemple sur un de mes PC à la maison la chaîne
correspond à la valeur 10128, mais sur un autre poste c'est 10129.
JMB77 a écrit :Je viens de tester et j'ai une erreur 423 NumberFormats, ce qui, si je ne me trompe pas, est Propriété ou méthode NumberFormats introuvable.
La méthode existe... et le fichier que je te communique fonctionne chez moi. Je pense que tu as mal retranscrit le code. L'erreur peut également venir du fait que tu ne passe pas le bon argument (le bon document) à la fonction
formatcolonne
Est-ce que tu as testé le fichier que je te communique ? Est-ce que tu as bien retranscrit les lignes suivantes dans la fonction
FormatChaine ?
Function FormatChaine(NewFic as Object, Chaine As String) As Long
...
oDoc = NewFic
Cordialement
Luke
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 04 juil. 2018 11:38
par JMB77
Luky-Luke.
Au risque de passer pour un demeuré, je vais expliquer ce que je viens de comprendre.
La fonction :
Code : Tout sélectionner
Function FormatChaine(NewFic as Object, Chaine As String) As Long
Dim oDoc As Object
Dim NbrFormats As Object
Dim Loc as New com.sun.star.lang.Locale
Dim formatID As Long
oDoc = NewFic
Loc.Language = "fr"
Loc.Country = "FR"
NbrFormats = oDoc.NumberFormats
formatId = NbrFormats.queryKey(Chaine, Loc, False)
If formatId = -1 Then
formatId = NbrFormats.addNew(Chaine, Loc)
End If
FormatChaine = formatID
End Function
permet de récupérer le code format à transmettre en args62() dans la ligne suivante :
Code : Tout sélectionner
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:NumberFormatValue", "", 0, args62())
Ça commence à s’éclaircir.
Je vais refaire l'implémentation du code et je te tiens au courant.
Merci pour tes conseils.
Avec l'habitude et des exemples c'est peut être facile, mais venant MsOffice, Excel et VBA c'est pas trop évident.
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 04 juil. 2018 11:51
par JMB77
Luky-Luke.
Désolé, j'ai toujours l'erreur.
Et voici le code :
Code : Tout sélectionner
Function FormatChaine(NewFic as Object, Chaine As String) As Long
Dim oDoc As Object
Dim NbrFormats As Object
Dim Loc as New com.sun.star.lang.Locale
Dim formatID As Long
oDoc = NewFic
Loc.Language = "fr"
Loc.Country = "FR"
NbrFormats = oDoc.NumberFormats
formatId = NbrFormats.queryKey(Chaine, Loc, False)
If formatId = -1 Then
formatId = NbrFormats.addNew(Chaine, Loc)
End If
FormatChaine = formatID
End Function
Ainsi que :
Code : Tout sélectionner
Sub formatcolonne(colonne, valR(), Arthur)
dim args61(0) as new com.sun.star.beans.PropertyValue
args61(0).Name = "ToPoint"
args61(0).Value = Lo_CelluleActive1
dim args62(0) as new com.sun.star.beans.PropertyValue
args62(0).Name = "NumberFormatValue"
dim args63(0) as new com.sun.star.beans.PropertyValue
args63(0).Name = "HorizontalJustification"
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
Li_len = len(Lo_CelluleActive1.absolutename)
Li_pos=InStr(Lo_CelluleActive1.absolutename,".")
Ls_cellule = right(Lo_CelluleActive1.absolutename,Li_len-Li_pos)
Ls_col_traitee = mid(Ls_cellule,2,1)
Li_pos_dollar=InStr(2,Ls_cellule,"$")
Ls_cel = mid(Ls_cellule, 2, Li_pos_dollar - 2)
Ls_select = ls_cel & "2:" & ls_cel & Ll_der_lig
args61(0).Value = Ls_select
If valR(1) = "O" Then
call replace_blanc(colonne)
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:GoToCell", "", 0, args61())
If valR(2) <> "" Then
If valR(2) = "C" Then
args63(0).Value = com.sun.star.table.CellHoriJustify.CENTER
ElseIf valR(2) = "G" Then
args63(0).Value = com.sun.star.table.CellHoriJustify.LEFT
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:HorizontalJustification", "", 0, args63())
End If
If valR(3) = "N" Then
args62(0).Value = FormatChaine(Lo_document1,"# ##0")
ElseIf valR(3) = "M" Then
args62(0).Value = FormatChaine(Lo_document1,"[$$-409]# ##0")
ElseIf valR(3) = "€" Then
args62(0).Value = FormatChaine(Lo_document1, "# ##0 [$€-40C]")
ElseIf valR(3) = "D" Then
args62(0).Value = FormatChaine(Lo_document1,"#0,00 [$€-40C]")
ElseIf valR(3) = "P" Then
args62(0).Value = FormatChaine(Lo_document1, valR(4))
End If
Lo_dispatcher1.executeDispatch(Lo_document1, ".uno:NumberFormatValue", "", 0, args62())
'--- libellé ---
If Arthur Then
Lo_CelluleActive1.string = valR(5)
End If
End Sub
Et plus précisément la partie appelante :
Code : Tout sélectionner
If valR(3) = "N" Then
args62(0).Value = FormatChaine(Lo_document1,"# ##0")
ElseIf valR(3) = "M" Then
args62(0).Value = FormatChaine(Lo_document1,"[$$-409]# ##0")
ElseIf valR(3) = "€" Then
args62(0).Value = FormatChaine(Lo_document1, "# ##0 [$€-40C]")
ElseIf valR(3) = "D" Then
args62(0).Value = FormatChaine(Lo_document1,"#0,00 [$€-40C]")
ElseIf valR(3) = "P" Then
args62(0).Value = FormatChaine(Lo_document1, valR(4))
End If
Je ne vois pas de différence.
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 04 juil. 2018 11:56
par Hubert Lambert
Bonjour à tous les deux,
JMB77 a écrit :Et puis, pour le dernier formatage
Si j'ai bien suivi votre échange, il suffira de faire :
Code : Tout sélectionner
ElseIf valR(3) = "P" Then
args62(0).Value = FormatChaine(Lo_newdossier, valR(4))
[/quote]
Par ailleurs, comme Lo_newdossier est une variable publique, elle peut être utilisée dans FormatChaine sans devoir la passer en paramètre
.
Cordialement.
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 04 juil. 2018 12:02
par JMB77
Super merci Luky-Luke.
Ça fonction super bien.
L'erreur que je commettais, était de mettre
Lo_document1 à la place de Lo_newdossier
Le code de la fonction reste inchangé, mais le code de la partie appelante devient alors :
Code : Tout sélectionner
If valR(3) = "N" Then
args62(0).Value = FormatChaine(Lo_newdossier,"# ##0")
ElseIf valR(3) = "M" Then
args62(0).Value = FormatChaine(Lo_newdossier,"[$$-409]# ##0")
ElseIf valR(3) = "€" Then
args62(0).Value = FormatChaine(Lo_newdossier, "# ##0 [$€-40C]")
ElseIf valR(3) = "D" Then
args62(0).Value = FormatChaine(Lo_newdossier,"#0,00 [$€-40C]")
ElseIf valR(3) = "P" Then
args62(0).Value = FormatChaine(Lo_newdossier, valR(4))
End If
Encore une fois super merci à tous.
Re: [Calc] Formatage "Aléatoire" colonne
Publié : 04 juil. 2018 12:07
par JMB77
Je clôture cette assistance.
Encore une fois grand merci