Hi all
need a little help
im tying to create a macro in word that will count each word length and store them in a varible.
For example if it counts the word two it would add one to the under5 varible e.g
VB Code:
If word.length <= 5 then"how ever this is done as this is my problem
under5 = under5 + 1
End If
so in short i need it to create around 5 varibles under5, under10, under15, under20 and under25
go through each word in the document (ebook) and then output the result some how however is easiest but so i can see it.
This is for my GCSE mathmatics invistigation just to give you an idea of why on earth I would want such a thing it is a statistics peice comparing adult books to childrens or in my case ebooks.
Thanks in advance Paul (Shorty)
If you = Good
then goto heaven
else goto hell
End If
That will be because nWord has been declared as a string variable data type & not a variant, also, all of the counter variables ARE variants. Try this one instead:
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Again thanks for everybody's help but there is still a problem wich im sure you great lot can solve for me as im so stupid.
When I excute the code it works fine for smaller texts but when I try to count up my ebook I come accross and error that error is Run-time error 6 overflow.
VB Code:
For intElementCounter = 0 To UBound(straryFullDocText) " This is what the debugger highlights
Thanks again for your help and this seams to be coming along beutifully
Oh and by the way my I.T teacher at school coulnt even work this one out.
Below I have attached Half of Alice in wonderland with the macro embeded just open and run the macro and you will see the problem
Thanks in advance Shorty
If you = Good
then goto heaven
else goto hell
End If
Oh and by the way my I.T teacher at school coulnt even work this one out.
If he's a vb programmer then backhand him, if he's a normal IT guy then fair enough, basically the integer data variable type can hold a number from -32,768 to 32,767, if your number you're trying to hold in one of the variables is above this, then you get this error.
Try changing all of the variables from an integer data type to a long data type which can support a greater numeric range from -2,147,483,648 to 2,147,483,647...
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details