1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| use Win32::OLE;
use Win32::OLE::Enum;
$document = Win32::OLE -> GetObject("C:\\Documents and Settings\\...\\perlWORD\\ficword.doc");
open (FH,">C:\\Documents and Settings\\...\\perlWORD\\fictexte.txt");
$paragraphs = $document->Paragraphs();
$enumerate = new Win32::OLE::Enum($paragraphs);
while(defined($paragraph = $enumerate->Next()))
{
$style = $paragraph->{Style}->{NameLocal};
print FH "<$style>";
$text = $paragraph->{Range}->{Text};
$text =~ s/[\n\r]//g;
$text =~ s/\x0b/\n/g;
print FH "$text</$style>\n";
} |
Partager