Sign in to follow this  
Followers 0

Find a string in TXT file problem

3 posts in this topic


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



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


    $line_tested = 0
    $trouver = 0
    $Rep = ""
    While 1
        $line_tested = $line_tested +1
        $line_to_test = FileReadLine($Convention,$line_tested)
        If $il_y_est = 1 Then
            $Rep = $Rep&@CRLF&FileReadLine($Convention,$line_tested)
            $trouver = 1
        If $line_tested = $line_number Then
    If $trouver = 0 Then
        MsgBox(16,"copie","non trouvé copie de ....")

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





Lettre type.txt

Share this post

Link to post
Share on other sites

Are you opening a .doc or a .docx be careful they are in no way the same.

You can't just change the extension to .txt

for .doc check doc

for .docx check docx

Have fun

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Share this post

Link to post
Share on other sites

it works fine thanks

Share this post

Link to post
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
Sign in to follow this  
Followers 0