#!perl -w use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; #my $wd = Win32::OLE::Const->Load("Microsoft Word 10.0 Object Library"); my $wd = Win32::OLE::Const->Load("Microsoft Word 9.0 Object Library"); my $Word = Win32::OLE->new('Word.Application', 'Quit'); #$Word->{'Visible'} = 1; # if you want to see what's going on my $doc = $Word->Documents->Open("C:\\temp\\test.doc") || die("Unable to open document ", Win32::OLE->LastError()); my $sel = $Word->Selection; $sel->WholeStory; my $pages = $sel->Information($wd->{'wdNumberOfPagesInDocument'}) || die("Unable to open property ", Win32::OLE->LastError()); print "The number of pages in test.doc are: $pages\n";