HP Envy x2 review: Hands-on
Can anyone help to to write a macro for MS Word to do the following?
I am a student and frequently write essays in Word. Most of the work I do has a word limit, so I use the word count feature regularly. However, quotations and citation references within the essay are not included in the limit.
I use the following method to get around this.
• Whenever I type something not included in the word limit, I put it in blue type.
• To count the words, I first to Find... and set, under More Options, the criterion that the font should be black.
• I then select the "Find all in Main Document" tickbox and click find. This highlights all the text I want to include in the word count.
• I can then run the word count feature as usual, but only the selected (i.e. non-quote) words are counted.
This works fine, except it's a bit long winded when I have to do it regularly. What I want therefore, is a macro which can:
• use the find tool to select all the black text (regardless of what font it's in or whether it's bold or italic etc).
• Run the word count feature and display the count summary.
• Stop once the summary is displayed so that I can read it and then click the close button on it's window once I have finished with it.
I have tried to do this using the Macro recording function several times, but without success. Two problems seem to occur when I try. Firstly, I can't click the Find button on the Find dialog box after setting the criterion to be black text because the macro recording is in operation. Secondly, when I click the word count option the summary is displayed, but then, with this as the active window, I am unable to click the stop button on the Macro recording toolbar and must close the window before this is possible, rendering the macro useless!
Many thanks in advance if you can help with this. I apologise if this is hard to follow - I am trying to explain as simply as I can what I need to do - but please let me know if I don't make sense!!
Had you considered putting all your 'not included words into text boxes? If you look at the helpfiles, you will see that the Word Count on the tools menu, does not count Words in the text boxes.
Don't forget to Word wrap your text boxes to square. If you want more explicit instructions on how to wrap the text round the text box or to do anything I've written here, let me know.
Thank you for your suggestion.
However, the text I don't want to include features in the body of the essay, i.e. within the lines of text I do want to include, not set out as an indented block. If that were the case, then it would be a good idea to use text boxes. However, it would be difficult to make the text look like a continuous passage using text boxes. The method of using blue text to avoid word counts described in my original posts works - it's just that having to first use find to to select the non-blue text before I can count the words is quite long-winded. This is why I ideally just want a macro that I can assign to a button and add to a toolbar.
As far as I knew, all features of Word should be able to operate through a macro?
"As far as I knew, all features of Word should be able to operate through a macro?"
Yes potentially they are but not all of them are recordable using the macro recorder. It is the same in Excel.
click here may help if you want to have a go at writing a macro from scratch.
It helped me out with something I was trying to do in Access.
I have bookmarked that page and will look over it when I have some time to spare. Much of the macro script seems to be recordable so I will try recording as much as possible and then editing it following the guide you sent to me.
In the meantime, though, I don't suppose you know the code yourself off by heart, do you? I was just wondering if you do, whether you might be able to help me put something together to get this done? It would definitely make you popular with students everywhere! :-)
Ha! Excel VBA, Yes but Word No, sadly. What version of Word are you using?
I'm using Word XP.
A facility to count words but exclude some is something I've been looking for in Word for a while - I think it would be great if you could flag certain words so they were excluded from word counts - that way it wouldn't be necessary to change the formatting (i.e. I wouldn't need blue text).
Working with blue text for the quotes and then having two copies of the document - one that has the text all in black for printing and another with the blue text so I can do accurate word counts - has provided a solution for some time. It is only just today that I realised I might be able to create a macro to automate finding the black text only and then performing the count. I've done very basic macros in Excel before, but nothing with Word. In fact, you helped me with an Excel one once...so I was kind of hoping you'd notice this thread!! :-)
click here may help you as well.
Sorry, I don't program in VBA for Word, only Excel.
Hopefully, you have used a paragraph style for the quotes. Try changing the blue text to hidden text or make it both blue and hidden. Hide the text to do the word count. Then remove the hidden attribute from the style when finished.
This thread is now locked and can not be replied to.