Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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.


Comment on Re^2: Word Documents->Count in Win32
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.

    Documents("Sales.doc").Activate

    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 :)

    /J

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2014-07-31 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls