Craig,
Ah, the joys of Word2000 and ActiveX...
1) About the word count including the TOC, you may be able to select a range
of the document that doesn't include the TOC, and then do your
ComputeStatistics on that selection. I'm not sure how Word delineates where
the TOC begins or ends, but since it's a just a big Field object it might be
fairly easy to isolate. Alternatively, you might find it easier to select
ONLY the TOC, do your ComputeStatistics on it, and then subtract that result
from the ComputeStatistics for the entire document. That would be kind of
backwards, but it is, after all, Microsoft that we're dealing with here.
😉
2) I've had this problem myself, and I don't remember exactly how I solved
it. I do remember that it wasn't very elegant. I have a few ideas:
a) Explicitly Quit Word after you're done processing the files. This may
be too inconvenient if you've already got Word running for some other
purpose.
b) I believe you can use another ActiveX call (forgot which one exactly)
to close the files and explicitly indicate to not save changes. Perhaps
you're doing that already, though, in which case your problem is a bit of a
mystery.
c) Turn off the Office Assistant. I have become very suspicious of the
little animated helper. The dialogs that the Assistant presents do not seem
to behave quite the same as the other "regular" dialogs you see when he's
turned off, and this has caused me difficulty in the past when working with
Word in "invisible" mode.
Sorry I can't be more specific, but I hope that helps a bit!
Justin
Justin J. Goeres
Project Engineer
jgoeres@indiosystems.com
phone (925)485-5083 ; fax (435)305-8044
Indio Systems, Inc.
5600-A Sunol Blvd.
Pleasanton, CA 94588
"Craig Graham" wrote in message
news:39fd8a27@newsgroups.ni.com...
> I'm trying to cobble together a VI that will, via ActiveX and MS Word2000,
> produce a table of the wordcounts of all the Word documents in a user
> specified directory. The sequence of operations is this;
>
> I list all the files in a directory ending .doc, and open a reference to
the
> Word application. The array of filenames goes into a for loop, and for
each
> file I get a reference to the "documents" property of Word, use the Open
> method on the documents object, specifying the filename I want and
> specifying that the file is to be opened read-only, not visible and not
> added to the recent file list. I then use the ComputeStatistics method on
> the new document to get the word count, before closing the "Close" method
on
> the new document object. Then I close the reference to the "Documents"
> object and, just in case, to the "Document" that I've just closed. The
loop
> then starts again. The reference to the Word application is closed when
the
> loop exits.
>
> The program works, kind of, however there are two problems;
>
> 1) Word is including tables of contents in the word count. Automatically
> generated tables should not be included in this word count since it's just
> Word making a copy of text elsewhere in the document.
>
> 2) When you go into Word afterwards to do anything and then close it you
are
> prompted to save changes to all the files opened by the VI, even though
you
> haven't touched the files yourself and the VI has both opened them read
only
> and specified that no changes are to be saved.
>
> Does anyone know how I could tackle these two problems? I'm not keen on
> trying to retrieve the text from Word and parse it to identify the end of
> the TOC...
>
>
>