Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Word Documents->Count in Win32

by esr (Scribe)
on Jan 08, 2005 at 01:09 UTC ( #420443=note: print w/replies, xml ) Need Help??

in reply to Re: Word Documents->Count in Win32
in thread Word Documents->Count in Win32

Alas, I wish that were true but the Documents object that was saved when the file was opened remains around as long as Word is active. Unfortunately the object reference points to trash. A similar thing happens with the $word object -- i.e. it stays around even if Word is closed but if I try to open another document using that object I get an error. Hence the code in the "else" block to undefine the $word object reference and get a new one. So the code snippet handles both cases where the user closes the document and where s/he closes Word instead.

Replies are listed 'Best First'.
Re^3: Word Documents->Count in Win32
by jplindstrom (Monsignor) on Jan 08, 2005 at 02:21 UTC
    Okay, this should work for the case when Word isn't closed. From the docs:

    Named Objects

    Although you can usually specify an integer value with the Item method, it may be more convenient to return an object by name. The following example switches the focus to a document named Sales.doc.


    You know the file name from opening, so when it doesn't return a valid Document object, that would indicate it's closed. Eh... in theory :)


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2016-10-23 12:04 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (301 votes). Check out past polls.