Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Open a word(.doc) file and output the number of pages contained in it

by guha (Priest)
on Nov 26, 2003 at 14:49 UTC ( #310268=note: print w/ replies, xml ) Need Help??


in reply to Open a word(.doc) file and output the number of pages contained in it

If you're on Win and have Word installed you can use Win32::OLE as Corion indicated above.

Below is a working example

#!perl -w use strict; use Win32::OLE; use Win32::OLE::Const; use Win32::OLE::Variant; ## Start Word engine my $Word = Win32::OLE->new('Word.Application', 'Quit'); $Word->{'DisplayAlerts'} = 0; my $wdc = Win32::OLE::Const->Load("Microsoft Word"); my $tpl = "c:\\perltest\\pages.doc"; ## Subject to change ## Open template my $doc = $Word->Documents->Open($tpl, {ReadOnly => Variant(VT_BOOL, +1) } ) || die"add"; my $pages = $Word->ActiveDocument->BuiltInDocumentProperties( $wdc->{w +dPropertyPages} )->Value; $doc->Close( { SaveChanges => $wdc->{wdDoNotSaveChanges} } ); print " $tpl contains $pages pages\n";
HTH


Comment on Re: Open a word(.doc) file and output the number of pages contained in it
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://310268]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-12-27 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls