my ($File, $Doc_dir); $Doc_dir = "C:\\word_files"; opendir(TEMP,$Doc_dir); while ($File = readdir(TEMP)) { unless ($File eq "." or $File eq "..") { my $f_check = substr($File,0,2); unless ($f_check eq '~$') { my $Full_File = "$Doc_dir\\$File"; my $f_name = substr($File,0,((length($File))-4)); my $Word = Win32::OLE->new( 'Word.Application', 'Quit' ) || die "Couldn't run Word"; my $Doc = $Word->Documents->Open($Full_File) || die "File does not exist or can not be opened"; # Text information my $num_pages = $Doc->ComputeStatistics(wdStatisticPages); my $num_paragraphs = $Doc->ComputeStatistics(wdStatisticParagraphs); my $num_lines = $Doc->ComputeStatistics(wdStatisticLines); my $num_words = $Doc->ComputeStatistics(wdStatisticWords); my $num_chars = $Doc->ComputeStatistics(wdStatisticCharacters); my $num_charWs = $Doc->ComputeStatistics(wdStatisticCharactersWithSpaces); my $header = $Doc->Sections(1)->Headers(wdHeaderFooterPrimary); my $h_num_pages = $header->Range->ComputeStatistics(wdStatisticPages); my $h_num_paragraphs = $header->Range->ComputeStatistics(wdStatisticParagraphs); my $h_num_lines = $header->Range->ComputeStatistics(wdStatisticLines); my $h_num_words = $header->Range->ComputeStatistics(wdStatisticWords); my $h_num_chars = $header->Range->ComputeStatistics(wdStatisticCharacters); my $h_num_charWs = $header->Range->ComputeStatistics(wdStatisticCharactersWithSpaces); my $footer = $Doc->Sections(1)->Footers(wdHeaderFooterPrimary); my $f_num_pages = $footer->Range->ComputeStatistics(wdStatisticPages); my $f_num_paragraphs = $footer->Range->ComputeStatistics(wdStatisticParagraphs); my $f_num_lines = $footer->Range->ComputeStatistics(wdStatisticLines); my $f_num_words = $footer->Range->ComputeStatistics(wdStatisticWords); my $f_num_chars = $footer->Range->ComputeStatistics(wdStatisticCharacters); my $f_num_charWs = $footer->Range->ComputeStatistics(wdStatisticCharactersWithSpaces); #$Word->Activedocument->Close (0); #$Doc->{Saved} = 0; #$Doc->Close(0); my $sys_com = "del $Full_File"; system ($sys_com); } } } close(TEMP); $dbh->disconnect;