Mobile menu

A MSWord macro to count the length of the text string?
Thread poster: xxxOTMed
xxxOTMed
Poland
Local time: 16:16
English to Polish
+ ...
Nov 23, 2004

Same situation as in the previous post.
Translation of SW strings in a MSWord table (optimistically assuming the txt was converted into doc, that is).
A couple of colums in the table including:
Column C - numeric - total allowed length of the text string for the entry
Column D - text - translated term

Now the question is whether any of you has come accross a macro/tool that would calculate the number of chars in column D, compare it to the number in column C and if the number of chars in column D is greater than the number in column C => highlight the text, blink, flash or send an email to the Head of QA.

What is quite frustrating is that I have already had such a tool from supplied by one of our clients. And of course, having searched every single xls from the past 2 years, have not found it to my sheer desperation.

Again, any help will be grossly appreciated.


Direct link Reply with quote
 

SysfilterMaker
Germany
Local time: 16:16
Macro counts length of string Nov 24, 2004

Hi,

here a macro for word. I have inserted some notes, so it is easy to change to your needs.

HTH

Regards from Germany
Wilhelm Polmann



Sub mLength()
' For free use and at your own risk
' Copyright by Wilhelm Polmann

Dim Wordlength As Integer
Dim WordNow As Integer

'If there are empty cells use in your table:
'On Error Resume Next

'Example for 4 columns

ActiveDocument.Tables(1).Rows(1).Cells(1).Select 'First Table in the document

For x = 1 To ActiveDocument.Tables(1).Rows.Count ' Start at first table, Column A, Row 1

' Move Selection, depends on number of columns
Selection.MoveRight Unit:=wdCell ' Jump to Column B
Selection.MoveRight Unit:=wdCell ' Jump to Column C

' Column C,
Wordlength = CInt(Selection.Text)

' Move Selection
Selection.MoveRight Unit:=wdCell 'Jump to Column D
WordNow = Len(Selection.Text)

' If Word too long then write "(Number of characters)characters too long"

If WordNow > Wordlength Then
Selection.MoveRight wdCharacter, 1
Selection.Font.Color = wdColorRed
Selection.TypeText Text:=WordNow - Wordlength & " characters too long"

' ' or:
' MsgBox "Oh no, text too long: " & _
' WordNow- Wordlength & _
' " Characters."
' Exit Sub

End If

Selection.MoveRight Unit:=wdCell ' Jump to Column A

Next x

End Sub


Direct link Reply with quote
 

Rossana Triaca  Identity Verified
Uruguay
Local time: 12:16
Member (2002)
English to Spanish
Excel... Nov 24, 2004

I've no idea about word, but what you want to do is really easy in Excel; you can copy&paste your two columns and add a third column with the following:

Column A
Allowed no of chars

Column B
Text

Column C
=IF(LEN(B1) < = A1;"OK";"ERROR")

This formula displays an OK if the number of characters in the text is the same or less than the number indicated in the first column or an ERROR label if not.

Since I am backtranslating from spanish I am not 100% certain that the function that gets the character length is actually LEN (my excel displays "LARGO", i.e., LENGTH), but it should be something of the sort (look it up under "text functions").

Hope it helps,
Rossana
p.d. Spaces in the formula are just to display it correctly in the post... there shouldn't be any in Excel!

[Edited at 2004-11-24 12:06]


Direct link Reply with quote
 

Magda Dziadosz  Identity Verified
Poland
Local time: 16:16
Member (2004)
English to Polish
+ ...
Moving this thread Nov 24, 2004

to the Office Application forum which is designed specifically to discuss MS Office.

Magda


Direct link Reply with quote
 
xxxOTMed
Poland
Local time: 16:16
English to Polish
+ ...
TOPIC STARTER
Thank you all for your input Nov 25, 2004

I do appreciate your time + effort.
I do realize Excel is much easier to do wordcounts in columns. the problem is it is much more comfortable to use Word table+Trados for this kind of work (lots of strings, fuzzies, reps + real time spell-check etc.).

I think the macro would most likely do the trick for us, but it would most likely need a bit of tuning up for our table. Will take the liberty of contacting wi_lee to show him/her the part we are still struggling with.

Thanks again, Greg


Direct link Reply with quote
 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

A MSWord macro to count the length of the text string?

Advanced search






memoQ translator pro
Kilgray's memoQ is the world's fastest developing integrated localization & translation environment rendering you more productive and efficient.

With our advanced file filters, unlimited language and advanced file support, memoQ translator pro has been designed for translators and reviewers who work on their own, with other translators or in team-based translation projects.

More info »
CafeTran Espresso
You've never met a CAT tool this clever!

Translate faster & easier, using a sophisticated CAT tool built by a translator / developer. Accept jobs from clients who use SDL Trados, MemoQ, Wordfast & major CAT tools. Download and start using CafeTran Espresso -- for free

More info »



All of ProZ.com
  • All of ProZ.com
  • Term search
  • Jobs