Jump to content

Find a string in TXT file problem


 Share

Recommended Posts

hello,

Excuse my english i'm french.

I try to do a script who find a string in a word document.

I lauch this script on computer who don't have Word installated (so i can't use the WORD.AU3 udf)

 

in my script, i replace the extension *.doc by *.txt.

If i open this txt with notepad i see my research but when i try to search the value with autoit, i have a problem.

if i open the document and save it, the script Works

But if i don't open the txt, it dosn't works.

 

In my script, if i don't open the txt file the $line_number variable stay to 1

If i open and save the txt before, the same variable has the value 74

 

have you an idea ? 

Or an other method to find a string in document word Without Word installated

 

thanks

$exist = FileExists($Convention)
If $exist = 0 Then
    MsgBox(16,"Erreur","Le fichier Lettre type.txt est introuvable à cet emplacement: " & $convention)
    Exit
EndIf
If $exist = 1 Then
    $line_number = _FileCountLines($Convention)

    MsgBox(16,"test",$line_number)

    $line_tested = 0
    $trouver = 0
    $Rep = ""
    While 1
        $line_tested = $line_tested +1
        $line_to_test = FileReadLine($Convention,$line_tested)
        MsgBox(16,"test",$line_to_test)
        FileWrite(@TempDir&"\temp_search",$line_to_test)
        $il_y_est=_ReplaceStringInFile(@TempDir&"\temp_search",$soutput2,"")
        If $il_y_est = 1 Then
            $Rep = $Rep&@CRLF&FileReadLine($Convention,$line_tested)
            $trouver = 1
        EndIf
        FileDelete(@TempDir&"\temp_search")
        If $line_tested = $line_number Then
            ExitLoop
        EndIf
    WEnd
    If $trouver = 0 Then
        MsgBox(16,"copie","non trouvé copie de ....")


    Else
        MsgBox(16,"copie","mot trouvé je copie ...")

    EndIf
endIf

 

 

 

Lettre type.txt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...