Bonjour

ci joint une ebauche faite rapidement en utilisant l'enregistreur de macro pour la partie rechercher/remplacer

je te laisse poursuivre/adapter

HTH

laurent

Ps: bon courage à la petit fille et ses parents

'-------------------------

Sub Main

        chemin_eml = "/home/lgodard/"
        fichier = dir(chemin_eml+"*.eml")
        while fichier<>""
                call traite_eml(chemin_eml+fichier)
                fichier = dir()
        wend
        
        msgbox "Fin du traitement du repertoire"
        
End Sub

sub traite_eml(fichier)

        dim prop(0) as new com.sun.star.beans.PropertyValue
        prop(0).name = "FilterName"
        prop(0).value = "Text"

doc = stardesktop.loadComponentFromURL(convertToURL(fichier),"_blank",0, prop())
        
        cherche = array("=E9", "=E0" ,"=9C" , "=E8" , "=F4" )
        remplace= array ("é","à","œ", "é", "ô")
        
        for i=lbound(cherche) to ubound(cherche)
                call rechercheRemplace(doc, cherche(i), remplace(i))
        next i


end sub


sub rechercheRemplace(doc, cherche, remplace)
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = doc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(18) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.StyleFamily"
args1(0).Value = 2
args1(1).Name = "SearchItem.CellType"
args1(1).Value = 0
args1(2).Name = "SearchItem.RowDirection"
args1(2).Value = true
args1(3).Name = "SearchItem.AllTables"
args1(3).Value = false
args1(4).Name = "SearchItem.Backward"
args1(4).Value = false
args1(5).Name = "SearchItem.Pattern"
args1(5).Value = false
args1(6).Name = "SearchItem.Content"
args1(6).Value = false
args1(7).Name = "SearchItem.AsianOptions"
args1(7).Value = false
args1(8).Name = "SearchItem.AlgorithmType"
args1(8).Value = 0
args1(9).Name = "SearchItem.SearchFlags"
args1(9).Value = 65536
args1(10).Name = "SearchItem.SearchString"
args1(10).Value = cherche
args1(11).Name = "SearchItem.ReplaceString"
args1(11).Value = remplace
args1(12).Name = "SearchItem.Locale"
args1(12).Value = 255
args1(13).Name = "SearchItem.ChangedChars"
args1(13).Value = 2
args1(14).Name = "SearchItem.DeletedChars"
args1(14).Value = 2
args1(15).Name = "SearchItem.InsertedChars"
args1(15).Value = 2
args1(16).Name = "SearchItem.TransliterateFlags"
args1(16).Value = 1280
args1(17).Name = "SearchItem.Command"
args1(17).Value = 3
args1(18).Name = "Quiet"
args1(18).Value = true

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())


end sub



---------------------------------------------------------------------
To unsubscribe, e-mail: prog-unsubscr...@fr.openoffice.org
For additional commands, e-mail: prog-h...@fr.openoffice.org

Répondre à