use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $filename = 'C:\temp\test.doc'; my $word = Win32::OLE->new('Word.Application', 'Quit'); my $doc = $word->Documents->Open($filename) || die("Unable to open document ", Win32::OLE->LastError()); my $nwords = $doc->Words->Count; my @wordtext; my @wordcolor; my $starttime = time; for(my $i = 1; $i <= $nwords; $i++) { $wordcolor[$i] = $doc->Words->Item($i)->HighlightColorIndex; $wordtext[$i] = $doc->Words->Item($i)->Text; } my $elapsed = time - $starttime; printf "\n\n%6.0D words\n%6.0D sec\n%5.3f per word", $nwords, $elapsed, $elapsed/$nwords; $doc->Close; undef $word;