PDA

View Full Version : Specific word count with VBA



adamcfishman
03-26-2012, 11:46 PM
Hello all,
I have been tasked with a project at work that I have hit a brick wall on. I have a MS Word doc in which I need to search the entire document for the words "Pass" and "Fail" the totals will need to be entered into a table 4 columns 2 row - Headers will be "Pass" "Fail" "Total" "Error Rate" with results below though I do NOT need VBA to create the table, just to be able to calculate the number of pass and fails individually. Also is there a way to auto calculate the totals without using F9 (a2+b2) and error rate ((b2/c2)*100"

Ultimately I would like to click one command bottom and have it all done for me, just wanting to know if it is possible and if so what is the best way for me to accomplish this?

Thank you all in advance for the support you are so willing to give.

Adam

fumei
03-27-2012, 12:25 AM
How is Word to know what "the totals" are? Just a total of the number of occurences of "Pass"? Does upper or lower case happen? Does it make a difference?

It is easy enough to get a count of any specific word. And to put that count at a specific location, say a cell in a table.

adamcfishman
03-27-2012, 12:34 AM
Yes totals are number of occurrences for pass and fail individually and case does not matter.

defcon_3
03-27-2012, 06:14 PM
Here to start with
http://word.tips.net/T001833_Generating_a_Count_of_Word_Occurrences.html

iCount would be responsible for the total.

fredlo2010
04-24-2012, 11:50 AM
I think it would be better if you use Excel VBA