J'ai trouvé un bout de code tout a fait fonctionnel pour extranre du texte de fichier .doc mais le seul probleme c'est que comme il utilise deux méthodes d'extraction de ne sais pas comment mettre mon return

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 my $input_file = 'test.doc';
 $input_file		= Win32::GetCwd() . "/$input_file" if $input_file !~ /^(\w:)?[\/\\]/;
 die "File $input_file does not exist" unless -f $input_file;
 
 my $word = Win32::OLE->new('Word.Application', 'Quit') || die "Couldn't run Word";
 my $doc = $word->Documents->Open($input_file);
 
 my $index = 0;
 
   # Extract using first method
   for my $paragraph (in $doc->Paragraphs)
   {
		$index++;
    	# Remove trailing ^M (the paragraph marker) from Range.
    	my($text) = substr($paragraph->Range->Text, 0, -1);
		print "Paragraph: $index. Text: <$text>\n\n";
   }
 
  print '-' x 50, "\n";
 
   # Extract using second method
    my $paraCount = $doc->Paragraphs->Count;
 
    for ($index = 1 ; $index <= $doc->Paragraphs->Count ; ++$index)
    {
        my($text) = $doc->Paragraphs($index);
	    print "Paragraph: $index. Text: <", $text->Range->Text, ">\n\n";
    }
 
   print '=' x 50, "\n";
   $doc->{Saved} = 1;
   $doc->Close;
Thx et bon codage