Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Dex
 
Posts: n/a
Default how to count words in specific font

I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jezebel
 
Posts: n/a
Default how to count words in specific font

Use Find and Replace to delete everything in italics (replace with nothing),
then count what's left.



"Dex" wrote in message
...
I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas?



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Cooz
 
Posts: n/a
Default how to count words in specific font

Hi Dex,

Record any macro, say record clicking the B-button on the Formatting
toolbar, and be sure to choose Normal.dot under 'Store macro in'.
Choose Tools | Macro Macro's..., select your macro and choose Edit. The
VBA-editor opens.
Replace the entire macro by the following:

Sub IgnoreItalics()
Dim lngWord As Long, lngCountIt As Long

lngCountIt = 0

For lngWord = 1 To ActiveDocument.Words.Count
If ActiveDocument.Words(lngWord).Italic Then
lngCountIt = lngCountIt + 1
End If
Next lngWord

MsgBox "Number of non-italic words: " & _
ActiveDocument.BuiltInDocumentProperties("Number of words") -
lngCountIt
End Sub

Click the Save button in the VBA editor to save Normal.dot. Close the VBA
editor. In Word, choose Tools | Macro Macros... Select IgnoreItalics and
click Run.

Note that if you have lengthy documents, this macro may take some time to
perform. My testdoc contains 1846 words and it took the macro 34 seconds from
start to finish.

Good luck,
Cooz
--
PS: If this is a satisfying answer to your question and you're logged in via
the Microsoft site, please click Yes to "Did this post answer the question?".
Thanks.



"Dex" wrote:

I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas?

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Dex
 
Posts: n/a
Default how to count words in specific font

thankyou!

"Jezebel" wrote:

Use Find and Replace to delete everything in italics (replace with nothing),
then count what's left.



"Dex" wrote in message
...
I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas?




  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Greg
 
Posts: n/a
Default how to count words in specific font

Cooz,

Did you perform even the most fundamental test on this proposed
solution before posting?

It doesn't work.

This is italic. This is not.

The result reported by your code is 2. The correct answer is 3.

Why do you get the wrong result. Word counts punctuation as a word.
So your counter counts "This" "is" "italic" and "." for a total of 4.
Number of words excludes punctuation and therefore returns 6. You do
the math.

So you might do this:

Sub IgnoreItalics1()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Content
With oRng.Find
.Font.Italic = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
MsgBox "Number of non-italic words: " &
ActiveDocument.BuiltInDocumentProperties("Number of words")
Undo
End Sub

Which is the what Jezebel suggests.



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Jezebel
 
Posts: n/a
Default how to count words in specific font

Apart from the idiotic advice to recording a macro then delete its contents,
your macro gives the wrong answer anyway: a document's Words collection
includes a lot of things that you wouldn't normally want to count as words.



"Cooz" wrote in message
...
Hi Dex,

Record any macro, say record clicking the B-button on the Formatting
toolbar, and be sure to choose Normal.dot under 'Store macro in'.
Choose Tools | Macro Macro's..., select your macro and choose Edit. The
VBA-editor opens.
Replace the entire macro by the following:

Sub IgnoreItalics()
Dim lngWord As Long, lngCountIt As Long

lngCountIt = 0

For lngWord = 1 To ActiveDocument.Words.Count
If ActiveDocument.Words(lngWord).Italic Then
lngCountIt = lngCountIt + 1
End If
Next lngWord

MsgBox "Number of non-italic words: " & _
ActiveDocument.BuiltInDocumentProperties("Number of words") -
lngCountIt
End Sub

Click the Save button in the VBA editor to save Normal.dot. Close the VBA
editor. In Word, choose Tools | Macro Macros... Select IgnoreItalics and
click Run.

Note that if you have lengthy documents, this macro may take some time to
perform. My testdoc contains 1846 words and it took the macro 34 seconds
from
start to finish.

Good luck,
Cooz
--
PS: If this is a satisfying answer to your question and you're logged in
via
the Microsoft site, please click Yes to "Did this post answer the
question?".
Thanks.



"Dex" wrote:

I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas?



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Cooz
 
Posts: n/a
Default how to count words in specific font

Jezebel,

If I should advise the average user to open the VBA-editor and paste code in
the code window, I would have to explain what and where the code window is. I
would have to explain how to navigate to the correct project. Other macros
might be visible - in which case the a.u. does not know if he should paste at
the top, at the bottom or anywhere else.
A simple, small recorded macro serves as a perfect placeholder.
If you think replacing this is idiotic - well, that is your problem.

Cooz


"Jezebel" wrote:

Apart from the idiotic advice to recording a macro then delete its contents,
your macro gives the wrong answer anyway: a document's Words collection
includes a lot of things that you wouldn't normally want to count as words.



"Cooz" wrote in message
...
Hi Dex,

Record any macro, say record clicking the B-button on the Formatting
toolbar, and be sure to choose Normal.dot under 'Store macro in'.
Choose Tools | Macro Macro's..., select your macro and choose Edit. The
VBA-editor opens.
Replace the entire macro by the following:

Sub IgnoreItalics()
Dim lngWord As Long, lngCountIt As Long

lngCountIt = 0

For lngWord = 1 To ActiveDocument.Words.Count
If ActiveDocument.Words(lngWord).Italic Then
lngCountIt = lngCountIt + 1
End If
Next lngWord

MsgBox "Number of non-italic words: " & _
ActiveDocument.BuiltInDocumentProperties("Number of words") -
lngCountIt
End Sub

Click the Save button in the VBA editor to save Normal.dot. Close the VBA
editor. In Word, choose Tools | Macro Macros... Select IgnoreItalics and
click Run.

Note that if you have lengthy documents, this macro may take some time to
perform. My testdoc contains 1846 words and it took the macro 34 seconds
from
start to finish.

Good luck,
Cooz
--
PS: If this is a satisfying answer to your question and you're logged in
via
the Microsoft site, please click Yes to "Did this post answer the
question?".
Thanks.



"Dex" wrote:

I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas?




  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Cooz
 
Posts: n/a
Default how to count words in specific font

Hi Dex,

Greg and Jezebel are right. Do not use the macro I suggested.
My humble apologies.

Cooz


"Dex" wrote:

I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas?

  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Greg
 
Posts: n/a
Default how to count words in specific font

Cooz,

Personnally I would rather you make the extra effort than continue the
practice that you use now as that is certainly not a perfect
suggestion. As an alternative, you could refer users to:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

or

http://www.gmayor.com/installing_macro.htm


What is the purpose of your post script? Does MS offer discounts or
some other compensation for the most questions answered?

  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill
 
Posts: n/a
Default how to count words in specific font

Nah, he's trying to get recognition as a Most Valuable Poster (or whatever
the stupid ranking system in the Communities is).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Greg" wrote in message
oups.com...
Cooz,

Personnally I would rather you make the extra effort than continue the
practice that you use now as that is certainly not a perfect
suggestion. As an alternative, you could refer users to:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

or

http://www.gmayor.com/installing_macro.htm


What is the purpose of your post script? Does MS offer discounts or
some other compensation for the most questions answered?




  #11   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill
 
Posts: n/a
Default how to count words in specific font

Tools | Macro | Macros | Create would accomplish the same thing much more
efficiently, however.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Cooz" wrote in message
...
Jezebel,

If I should advise the average user to open the VBA-editor and paste code

in
the code window, I would have to explain what and where the code window

is. I
would have to explain how to navigate to the correct project. Other macros
might be visible - in which case the a.u. does not know if he should paste

at
the top, at the bottom or anywhere else.
A simple, small recorded macro serves as a perfect placeholder.
If you think replacing this is idiotic - well, that is your problem.

Cooz


"Jezebel" wrote:

Apart from the idiotic advice to recording a macro then delete its

contents,
your macro gives the wrong answer anyway: a document's Words collection
includes a lot of things that you wouldn't normally want to count as

words.



"Cooz" wrote in message
...
Hi Dex,

Record any macro, say record clicking the B-button on the Formatting
toolbar, and be sure to choose Normal.dot under 'Store macro in'.
Choose Tools | Macro Macro's..., select your macro and choose Edit.

The
VBA-editor opens.
Replace the entire macro by the following:

Sub IgnoreItalics()
Dim lngWord As Long, lngCountIt As Long

lngCountIt = 0

For lngWord = 1 To ActiveDocument.Words.Count
If ActiveDocument.Words(lngWord).Italic Then
lngCountIt = lngCountIt + 1
End If
Next lngWord

MsgBox "Number of non-italic words: " & _
ActiveDocument.BuiltInDocumentProperties("Number of words") -
lngCountIt
End Sub

Click the Save button in the VBA editor to save Normal.dot. Close the

VBA
editor. In Word, choose Tools | Macro Macros... Select IgnoreItalics

and
click Run.

Note that if you have lengthy documents, this macro may take some time

to
perform. My testdoc contains 1846 words and it took the macro 34

seconds
from
start to finish.

Good luck,
Cooz
--
PS: If this is a satisfying answer to your question and you're logged

in
via
the Microsoft site, please click Yes to "Did this post answer the
question?".
Thanks.



"Dex" wrote:

I need to be able to word-count only the words in normal text and

ignore
words in italics, any ideas?





  #12   Report Post  
Posted to microsoft.public.word.docmanagement
Cooz
 
Posts: n/a
Default how to count words in specific font

Hi Suzanne,

Yep, you are right.

You're a Most Valuable Poster yourself - how did you get recognition as a
Most Valuable Poster if not by means of the stupid ranking system in the
Communities?

Cooz



"Suzanne S. Barnhill" wrote:

Nah, he's trying to get recognition as a Most Valuable Poster (or whatever
the stupid ranking system in the Communities is).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Greg" wrote in message
oups.com...
Cooz,

Personnally I would rather you make the extra effort than continue the
practice that you use now as that is certainly not a perfect
suggestion. As an alternative, you could refer users to:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

or

http://www.gmayor.com/installing_macro.htm


What is the purpose of your post script? Does MS offer discounts or
some other compensation for the most questions answered?



  #13   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill
 
Posts: n/a
Default how to count words in specific font

No, I'm a Most Valuable Professional. That's an entirely different thing;
see https://mvp.support.microsoft.com/mvpfaqs

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Cooz" wrote in message
news
Hi Suzanne,

Yep, you are right.

You're a Most Valuable Poster yourself - how did you get recognition as a
Most Valuable Poster if not by means of the stupid ranking system in the
Communities?

Cooz



"Suzanne S. Barnhill" wrote:

Nah, he's trying to get recognition as a Most Valuable Poster (or

whatever
the stupid ranking system in the Communities is).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup so
all may benefit.

"Greg" wrote in message
oups.com...
Cooz,

Personnally I would rather you make the extra effort than continue the
practice that you use now as that is certainly not a perfect
suggestion. As an alternative, you could refer users to:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

or

http://www.gmayor.com/installing_macro.htm


What is the purpose of your post script? Does MS offer discounts or
some other compensation for the most questions answered?




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlighting specific words jezzica85 Microsoft Word Help 22 April 2nd 06 10:31 AM
Count specific words in MS Word Fabian Microsoft Word Help 1 February 10th 06 12:38 PM
How to count occurances of specific words or phrases in a Word doc gcarr Microsoft Word Help 1 February 8th 06 08:56 PM
Deleting Old Versions of Fonts Lana A Li Microsoft Word Help 5 September 1st 05 09:51 PM
format the font to a specific size GretaGreenatGSSS Microsoft Word Help 1 June 15th 05 12:02 AM


All times are GMT +1. The time now is 08:11 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"