Creating Word macro for searching&replacing strings?
Thread poster: Cilian O'Tuama

Cilian O'Tuama  Identity Verified
Local time: 11:14
German to English
+ ...
Jun 6, 2003

Hi All,

I've been asked for a quote on a huge Word file with zillions of strings of different lengths, which of course will not have to be translated. All are contained within square brackets ( [blabla...] ). The strings consist of letters, numbers and other symbols. There are so many of these strings that I can't include them in my word/line count.

Does anyone know how to create a Word macro (if possible in Word 97) that can replace all of these strings, irrespective of length and content, in a single operation?

If this has been discussed before, a pointer in the right direction would be appreciated.

Thanks,
Cilian


Direct link Reply with quote
 

Beatrice T  Identity Verified
Italy
Local time: 11:14
Member (2010)
German to Italian
+ ...
You can try with wildcards Jun 6, 2003

Hi Cilian,
I hope I got the point
try this: (in any Word version, 95, 97, 2000)
Edit>
Find: \[*\]
Replace: what you want this string to be replaced with

Check the checkbox "Use wildcards"

If you like, you can register this operation as a macro, obviously.
Hope it is of any help.

Bye!


Direct link Reply with quote
 

jmadsen  Identity Verified
Local time: 11:14
Have you tried Search & Replace? Jun 6, 2003

I always use the Search and Replace utility (www.funduc.com) for this kind of operation, including glossary lookups.
It has many useful features, including searching and replacing * strings (not possible in Word) with or without confirmation.
Good luck,
Jørgen


Direct link Reply with quote
 

Klaus Herrmann  Identity Verified
Germany
Local time: 11:14
Member (2002)
English to German
+ ...
UltraEdit Jun 6, 2003

Did you ever try UltraEdit ? It's the perfect tool for this purpose. You can download a 30-day trial version from www.ultraedit.com.

Direct link Reply with quote
 

Gerard de Noord  Identity Verified
France
Local time: 11:14
Member (2003)
German to Dutch
+ ...
A macro is not really necessary Jun 6, 2003

Hi Cilian,

In this case you could simply replace \[*\] with nothing in a copy with the file. Use wildcards and think about removing double spaces, if necessary.

Regards,
Gerard


Direct link Reply with quote
 
xxxMarc P  Identity Verified
Local time: 11:14
German to English
+ ...
Searching/replacing strings Jun 6, 2003

Hi Cilian,

If I've understood you correctly, all you want to do is delete all instances of [...] from the text, in order to be able to count the remaining text.

If that's the case, then simply check the "Use wildcards" option in the search & replace dialog and enter

backslash - open square bracket - asterisk - backslash - close square bracket (as you've probably realized by now, ProZ is playing havoc with our efforts to enter this literally)

as the search term. Leave the replace field blank.

"*" represents "0 or more characters", and the backslash indicates that the brackets are to be interpreted literally, as they otherwise have a special function of their own. This works for Office 97.

Marc


[Edited at 2003-06-06 14:50]


Direct link Reply with quote
 

Deborah Shannon  Identity Verified
Germany
Local time: 11:14
Member (2002)
German to English
Search and replace/special, with wildcards Jun 6, 2003

Cilian O'Tuama wrote:

All are contained within square brackets ( [blabla...] ). The strings consist of letters, numbers and other symbols. There are so many of these strings that I can't include them in my word/line count.



Hi Cilian,

If it's for a one-off quote, I'd find it just as quick to use a few search-and-replace operations.

The symbol * stands for 'any string' in a wildcard search and replace. The problem is that your expressions are contained in square brackets, which Word Advanced search and replace otherwise uses for special purposes.

So, first I'd replace the all left and the right square brackets with something which does not occur elsewhere in the document (e.g. LEFTBRACKET for all the left ones and RIGHTBRACKET for all the right ones).

That's two operations.

Step 3: Search the string LEFTBRACKET*RIGHTBRACKET with More/'Wildcards' or 'Pattern matching' activated, and Replace with Format/Highlight or a particular text colour to make the non-translatable text stand out visually.

If you're using a translation tool, you replace the strings with the non-translatable style (telling the tool not to count them or present them for translation, which would obviate the need for step 4).

Step 4: search for the Highlight (text colour, style, whatever) and replace with nothing, i.e. delete it, so that you can count the remaining words. (Obviously this would all be done on a copy of the file...)

Also, don't forget to reinstate the brackets after translation!

All the best, Deborah


Direct link Reply with quote
 

Cilian O'Tuama  Identity Verified
Local time: 11:14
German to English
+ ...
TOPIC STARTER
Problem solved Jun 6, 2003

Cheers Everyone - I followed Marc's edited (thanks) instructions and lo and behold...

I must admit I was confused - backslash, what backslash!

Another slight drawback was that I only have German versions of Word, and who could guess that 'with wildcard' = 'mit Mustervergleich'!?

Thanks again.
Cilian


Direct link Reply with quote
 
Robert Zawadzki  Identity Verified
Local time: 11:14
English to Polish
+ ...
For me \[*\] works Jun 6, 2003

When wildcards are turned on, [ has a special meaning.

Gerard de Noord wrote:

Hi Cilian,

In this case you could simply replace
  • with nothing in a copy with the file. Use wildcards and think about removing double spaces, if necessary.

    Regards,
    Gerard


  • 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 »

    Creating Word macro for searching&replacing strings?

    Advanced search






    WordFinder
    The words you want Anywhere, Anytime

    WordFinder is the market's fastest and easiest way of finding the right word, term, translation or synonym in one or more dictionaries. In our assortment you can choose among more than 120 dictionaries in 15 languages from leading publishers.

    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 »



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