Document Statistics Without Opening a Document 
Author Message
 Document Statistics Without Opening a Document

I need to know how many paragraphs a document has without
opening it first.  I know I can use the following if the
document is open:

ComputeStatistics(Statistic:=wdStatisticParagraphs)

I need to check the documents statistics *without* opening
it (so I can determine whether to open it or not).  I know
the information is available, because I can get it under
Properties, Summary when I right click on a file, but I
don't know how to do it programatically.

Thanks,

Stuart



Wed, 25 Aug 2004 01:20:34 GMT  
 Document Statistics Without Opening a Document
Hi Stuart,

You might try the following:

Dim oDoc As Document
Set oDoc = GetObject("C:\Test.doc")
Debug.Print oDoc.ComputeStatistics(Statistic:=wdStatisticParagraphs)
oDoc.Saved = True
oDoc.Close
Set oDoc = Nothing

It does _not_ open the document in the Word window; it opens the document
programmatically, which allows you to access its object model and
change/read anything you want.

HTH

Quote:
> I need to know how many paragraphs a document has without
> opening it first.  I know I can use the following if the
> document is open:

> ComputeStatistics(Statistic:=wdStatisticParagraphs)

> I need to check the documents statistics *without* opening
> it (so I can determine whether to open it or not).  I know
> the information is available, because I can get it under
> Properties, Summary when I right click on a file, but I
> don't know how to do it programatically.

> Thanks,

> Stuart



Wed, 25 Aug 2004 02:02:41 GMT  
 Document Statistics Without Opening a Document
Thanks very much.  That is exactly what I need to do.

Stuart

Quote:
>-----Original Message-----
>Hi Stuart,

>You might try the following:

>Dim oDoc As Document
>Set oDoc = GetObject("C:\Test.doc")
>Debug.Print oDoc.ComputeStatistics

(Statistic:=wdStatisticParagraphs)
Quote:
>oDoc.Saved = True
>oDoc.Close
>Set oDoc = Nothing

>It does _not_ open the document in the Word window; it
opens the document
>programmatically, which allows you to access its object
model and
>change/read anything you want.

>HTH


>> I need to know how many paragraphs a document has
without
>> opening it first.  I know I can use the following if the
>> document is open:

>> ComputeStatistics(Statistic:=wdStatisticParagraphs)

>> I need to check the documents statistics *without*
opening
>> it (so I can determine whether to open it or not).  I
know
>> the information is available, because I can get it under
>> Properties, Summary when I right click on a file, but I
>> don't know how to do it programatically.

>> Thanks,

>> Stuart

>.



Wed, 25 Aug 2004 02:13:46 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Opening new document without a new window opening

2. Trouble Opening a Word Document with VB.NET,Open member not found in Documents

3. Copy a document but without the document template

4. Document properties without opening it

5. Custom Properties - without opening a Word document??

6. Adding text to a document without opening it.

7. Set file properties without opening the document?

8. Retrieve pagesetup-values without opening the document

9. Open document without MRU update

10. Opening Merge Document tries to remerge the document

11. Make a Text File without opening as document?

12. Accessing Document Variables without opening the file

 

 
Powered by phpBB® Forum Software