Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I need to be able to word-count only the words in normal text and ignore
words in italics, any ideas? |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
Highlighting specific words | Microsoft Word Help | |||
Count specific words in MS Word | Microsoft Word Help | |||
How to count occurances of specific words or phrases in a Word doc | Microsoft Word Help | |||
Deleting Old Versions of Fonts | Microsoft Word Help | |||
format the font to a specific size | Microsoft Word Help |