Après bon nombre de recherches (3 mois et j'y suis presque), je ne parviens pas a trouver la solution,
L' objectif est de remplacer 4 mots dans un texte disposé un peu partout, mais attention le fichier est en .odt (libreoffice)
Les 4 mots : FOURNISSEUR / ADRESSE /CP / NUMERO par des champs que j'aurais pré-rempli.
Base : Je possede un script en DRAG AND DROP, je depose le fichier, ensuite il doit s'ouvrir, les mots doivent être remplacer,
et pour finir je dois imprimer le document.
Mon script est presque fini mais contient surement une ou plusieurs erreurs.
Exemple d'execution :
Pour l'execution avoir un fichier en .odt dont TEST.odt avec ces mots à l'interieur FOURNISSEUR / ADRESSE /CP / NUMERO.
Merci par avance!
Script :
Code: Select all
Gui:
Gui Add, Edit, x80 y10 w100 h20 vFRS2
Gui Add, Edit, x80 y40 w100 h20 vADRESSE
Gui Add, Edit, x80 y70 w100 h20 vCP
Gui Add, Edit, x80 y100 w100 h20 vREJET
Gui Add, Text, x2 y0 w76 h39 +0x200, FRS
Gui Add, Text, x2 y30 w76 h39 +0x200, ADRESSE
Gui Add, Text, x2 y60 w76 h39 +0x200, CP
Gui Add, Text, x2 y90 w76 h39 +0x200, REJET
Gui Add, Button, x215 y88 w40 h20 gEFF , EFF
Gui Add, Edit, x2 y130 w250 h20 vcmd_name section, cmd_name
Gui add, edit, x2 y160 w250 h20 vcmd_path, cmd_path
Gui show
return
GuiDropFiles:
parameter := A_GuiEvent
gosub parse_cmd
return
parse_cmd:
Loop , parse, parameter, `r`n
{
dropfile_path = %A_LoopField%
SplitPath , dropfile_path, ,,,dropfile_name
Break
}
GuiControl ,, cmd_name, %dropfile_name%
GuiControl ,, cmd_path, %dropfile_path%
Run, %dropfile_path%
Sleep,2000
Path := "%A_LoopField%"
ButtonOK:
{
Gui, Submit, NoHide
FileRead, Var1, %dropfile_path%
;~ or
;~ FileRead, Var1, %dropfile_path%
{
StringReplace, Var1, Var1, FOURNISSEUR, %FRS2%
StringReplace, Var1, Var1, ADRESSE, %ADRESSE%
StringReplace, Var1, Var1, POSTAL, %CP%
StringReplace, Var1, Var1, NUMERO, %REJET%
;~ All of these are equivilent
FileAppend, %Var1%`n, %dropfile_path%\TEST2.odt, UTF-8 ; The "Path" variable assigned previously
;~ or
;~ FileAppend, %Var1%`n, %A_Desktop%\TEST2.odt, UTF-8
;~ or
;~ FileAppend, %Var1%`n, C:\Users\alaudicina-cp\Desktop\TEST2.odt, UTF-8
}
return
}
EFF:
GuiControl,, FRS2
GuiControl,, ADRESSE
GuiControl,, CP
GuiControl,, REJET
GuiControl, Choose, CODE,0
Sleep, 200
return