I am trying to use the following code to grab the number of pages from a word document. I get the following error:
Unable to open property Win32::OLE(0.1501) error 0x80020011: "Does not + support a collection" in METHOD/PROPERTYGET "" at pdf_testing.pl line 31.
in the MS doc I found that I should be able to use
object.Information(wdNumberOfPagesInDocument)
I translated as below and several other permutations for Perl. If anyone can help me on this, I would appreciate it.
use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $wd = Win32::OLE::Const->Load("Microsoft Word 10.0 Object Library") +; my ($pages,$doc); 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("P:\\My DOCUMENTS\\test.doc") || die("Unable to open document ", Win32::OLE->LastError()); $pages = $doc->Information($$wd{'wdNumberOfPagesInDocument'}) || die(" +Unable to open property ", Win32::OLE->LastError()); print "The number of pages in test.doc are: $pages"; exit;

g_White


In reply to Win32::OLE + word page count by gwhite

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.