PDA

View Full Version : count bold text



saban
10-09-2006, 02:30 AM
I have a big document which contains a lot of bold text and now I must distribute this document amongst 3 people and each of them should get the same amount of bold text

Any ideas how to do this
thnx

Actually I want for start, just count all bold text
How can I do that

mdmackillop
10-09-2006, 10:59 AM
Try

Sub BoldWords()
For Each w In ActiveDocument.Words
If w.Font.Bold = True Then cntB = cntB + 1
cnt = cnt + 1
Next
third = Int(cntB / 3)
For Each w In ActiveDocument.Words
If w.Font.Bold = True Then cB = cB + 1
If cB = third Then
k = k + 1
w.Select
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText String(20, "*")
third = Int(2 * cntB / 3)
If k = 2 Then Exit Sub
End If
Next
End Sub

saban
10-10-2006, 07:53 AM
Thnx I will try this

fumei
10-10-2006, 09:50 AM
1. If you want them to get the same thing...why not just send them the same thing?

2. md - could you explain your code? I am not sure why you are doing what you are doing. You can get a count of bold words with:Option Explicit

Sub CountBoldWords()
Dim oRange As Word.Range
Dim oWord As Object
Dim i As Integer
Set oRange = ActiveDocument.Range
For Each oWord In oRange.Words
If oWord.Font.Bold = True Then
i = i + 1
End If
Next
MsgBox "There are " & i & _
" bold words in the document."
End SubI would like to know why you are doing any Selection at all.

mdmackillop
10-10-2006, 10:03 AM
Hi Gerry,
I'm not so familiar with ranges etc. in Word, so sometimes I resort to the recorded stuff!
Saban wanted some way to split the document ( I think). The intention of my code is to insert a row of asterisks after 1/3 and 2/3 of the bold words have been counted. This can be changed to breaks or whatever. As I was guessing at the real intention here, I just went for the "easy option"

fumei
10-10-2006, 11:51 AM
Oh...OK, that sort of makes sense. I am not sure what is being asked either. I did not think about separating the bold words.

Saban, could you please explain what it is you want to do?

saban
10-12-2006, 05:46 AM
Ofcourse It is like this :
Document consists of text that is bold Italic and normal and now I must distribute this document to translators evenly. That means that each of translators should get the same quantity of bolded text to translate.
But I cant divide document into multiple parts instead I just mark them with comments. The comments are displaying limit between bolded text for one translator

Lets put it another way:
there are 300 characters of bold text in whole document (to get this info I must count them)
Now when I got information on how many characters there are I need to divide this, with number of translators working on this document so i get the result how many bolded characters should one translate

Next step is go to the begining of the document and start counting bold characters till you come to 100 (if there are 3 translators 300/3)
When it comes to 100 bold characters insert a comment which says there are 100 bold characters

Now select this comment set start position go to previous comment (at the very beggining I ve inserted one comment) and set its start position now select this range and count all the characters in selection (wdStatisticCharacters) and calculate = "all the characters in selection"-"bolded characters" So I get the result of how many non-bolded text there is and insertt this information into another comment
And now I would like to have 3 informations bolded text italic and normal but the document needs to be divided according to number of bolded text italic and normal text number are just for information


Thnx for all your help
p.s (one more thing how do I loop to end position which is stored in variable as position, because somehow I cant manage to do count for italic text but only to comment which indicates that there are same number of bold text below and above the comment)

mdmackillop
10-12-2006, 08:06 AM
Hi Saban,
It's time again for some input from yourself. My routine is a fair step along the way.
Let us know of any specific problems that you have.
Regards
MD

saban
10-12-2006, 08:36 AM
Yes I know and I already did it and I realize that you for next statement was just what i needed. I have only a few minor problems which I think will be able to solve

So Thnx for all your time I really appreciate it
(And if i ran into some trouble I will let you know)

Stay cool
Saban

saban
10-13-2006, 01:45 AM
I have one question how can I count characters with no spaces because your method counts it with spaces

saban
10-13-2006, 02:40 AM
Set oRangeBold1 = ActiveDocument.Range
For Each oWordbold1 In oRangeBold1.Characters
If oWordbold1.Font.Bold = True Then
iBold1 = iBold1 + 1
****1 = iBold1
End If
If ****1 >= rezultat Then
Selection.Collapse Direction:=wdCollapseEnd
Selection.Comments.Add Range:=Selection.Range
Selection.TypeText Text:=("till here it is : " & ****1 & " characters of bold text")
ActiveWindow.ActivePane.Close
GoTo prov
End If
Next
prov: ****1 = Empty


Can you help me with this one how can I insert this comment on actual position of ****1 (fo instance on 200)

saban
10-13-2006, 03:37 AM
Never mind I 've figured it out it is oWordbold1.Select

saban
10-16-2006, 12:32 AM
For Each oWordbold1 In oRangeBold1.Characters
If oWordbold1.Font.Italic= True Then
iBold1 = iBold1 + 1
End If
Next


the code above counts the Italic characters but it also counts characters that are boldItalic is it possible somehow to count just Italic
and not BoldItalic also

mdmackillop
10-16-2006, 12:41 AM
If oWordbold1.Font.Italic = True And oWordbold1.Font.Bold = False Then

saban
10-16-2006, 02:32 AM
thnx man i'll try this but my poor logic tels me it will work :)

Stay cool

saban
10-16-2006, 02:49 AM
ignore this reply

Thnx
Stay cool

fumei
10-17-2006, 01:30 AM
I have to say that this is very very strange stuff. Counting characters to separate to individual translators....weird, very very weird.

saban
10-18-2006, 02:47 AM
That is because bolded text was never translated unlike the normal text which is already in database of Trados