Compute Statistics function fails to work

D

Dugald

I have a VBA macro that uses the ComputeStatistics method to calculate the
page that a paragraph is on like so:
Set myRng = myPara.Range
myRng.Start = 0
intPage = myRng.ComputeStatistics(wdStatisticPages)

and it works great for almost all the Word documents that I use it on,
however I have one file that simply will not calculate the statistics on a
Range (even the currently selected Range). In this file, the
ComputeStatistics method always returns 0 for every statistic type in every
range that I create. I tried adding the Word Count toolbar to the file and I
noticed that the Word Count toolbar always shows the page or word count for
the entire file - never for the current selection; wheras in other files the
Word Count toolbar shows the statistics for the currently selected range.

Does anyone know why the ComputeStatistics method would fail in a particular
Word file? The files I'm working with have essentially got the same layout,
they're based on the same template and use the same styles. I'm working in
Word 2003 on Windows XP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top