feregreatest.blogg.se

Microsoft word numwords wrong
Microsoft word numwords wrong




microsoft word numwords wrong

" will count as 5 words, because the period has a leading space. "Word" in ComputeStatistics is any character(s) with either leading or trailing space. In this case ComputeStatisics will count the period as a word. Result: 1 2īoth ComputeStatistics, are "wrong"

microsoft word numwords wrong

includes in its count, the period at the end, AND the paragraph mark as "words". Select the text, without the paragraph mark. Select it the text, including the paragraph mark. "This is some text." This is ended with a paragraph mark. NumWords = r.ComputeStatistics(wdStatisticWords) Public Function NumWords(r As Range) As Long NumSpaces = r.ComputeStatistics(wdStatisticCharactersWithSpaces) - _ I keep some ComputeStatistics values as Functions.Public Function NumSpaces(r As Range) As Long However, using some of those WITH ComputeStatistics can be very useful. True, you can use InStr, Mid, Left, Right etc. Say you have a string, part of a paragraph, selected. And it has handy returnable values.īetween these three you can deduce a lot of information about a string (set as a Range of course), and play with it.

microsoft word numwords wrong

You can not use ComputeStatistics with Selection. The second reason is that it is a property of Range and Document. It obtains a value from ONE object, rather than calculating TWO values from two. In the example above, I think it is preferable for the reason I stated. I think it is because it forces Word to actually compute. Generally, ComputeStatistics is more accurate. It may be worth your while to do some experimenting, comparing ComputeStatistics and Information. There is lot to be gained from the Help files in Word, but yes, I agree that they do leave a lot to be desired. Sections(Sect - 1) - Section(0) does not exist. The dreaded Error 5941: The requested member of the collection does not exist. Sections(Sect - 1).Range.Information(wdActiveEndPageNumber)will abort the procedure with a fatal error. Sections(Sect).Range.Information(wdActiveEndPageNumber) - _

MICROSOFT WORD NUMWORDS WRONG CODE

I would further point out that if Malcolm's code is executed on Section 1, then: Pgs =. The main advantage of using the actual Range compute statistics, is of course, that you do not have calculate values from TWO sections (the current one, and the one previous). This would occur for the last section of a document. You could of course get the value and subtract 1.except if the Range made of the Section does NOT include a section break.then the value is, in fact, correct. Therefore, unless you back the End up, the number of pages will off by +1. The important thing about using ComputeStatistics on a Range of a Section is that setting a Range includes the following Section break. Rng.SetRange Start:=Rng.Start, End:=Rng.Start - 1 'If pages/2 = 0 then even number, so do process Sections(Sect - 1).Range.Information(wdActiveEndPageNumber) This code tidies up and removes the Selection procedures. I'm not sure if you need the extra page breaks if BreakOddPage is used. Information(3) uses the integer value of Information(wdActiveEndPageNumber) (which I copied from Help) 'For checking - next 3 lines can be deleted 'Insert page break to make odd number of pages in the section 'If pages/2 0 then even number so do process 'Get pages from start to end of current and previous sections. Sect = Selection.Information(wdActiveEndSectionNumber) This needs a bit more work, but no more time just now






Microsoft word numwords wrong