Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find and replace equations (Latin characters)

7 views
Skip to first unread message

fogh...@lycos.com

unread,
Jul 6, 2006, 11:27:23 AM7/6/06
to
I am editing a Latin course that was created in Word 5. All the Latin
characters (the vowels with the bar above it) were put in using a code:
(o,¯) so that the letter appears correctly.

When opening the document in Word 98 or 2004 it inserts those
characters as an equation:
{ EQ \o(o,¯) } They still appear correctly, but now there is a space
after each character, so now there are spaces in the middle of a word:
(eo rum) instead of (eorum).

I have found a work around in Word 5 by doing a lot of search and
replacing the code with the proper Times CE character, but I have
several hundred pages to do and this will take a long time. I don't
know if Word 5 supports macros (I don't have the help files anymore, I
don't even know how to increase the view from 100% to 200% or higher).

Is there a way in Word 98/2004 to search for the equations and either
1) removing the extra space or 2) replacing the equation entirely with
the Times CE character? And would I be able to use a macro for this?
(I'm not skilled at scripting macros, I usually record them)

Any help at all would be greatly appreciated.

Thank you.

Elliott Roper

unread,
Jul 6, 2006, 7:02:09 PM7/6/06
to
In article <1152199642....@m73g2000cwd.googlegroups.com>,
<fogh...@lycos.com> wrote:

> I am editing a Latin course that was created in Word 5. All the Latin
> characters (the vowels with the bar above it) were put in using a code:

> (o,Ż) so that the letter appears correctly.


>
> When opening the document in Word 98 or 2004 it inserts those
> characters as an equation:

> { EQ \o(o,Ż) } They still appear correctly, but now there is a space


> after each character, so now there are spaces in the middle of a word:
> (eo rum) instead of (eorum).
>
> I have found a work around in Word 5 by doing a lot of search and
> replacing the code with the proper Times CE character, but I have
> several hundred pages to do and this will take a long time. I don't
> know if Word 5 supports macros (I don't have the help files anymore, I
> don't even know how to increase the view from 100% to 200% or higher).
>
> Is there a way in Word 98/2004 to search for the equations and either
> 1) removing the extra space or 2) replacing the equation entirely with
> the Times CE character? And would I be able to use a macro for this?
> (I'm not skilled at scripting macros, I usually record them)
>
> Any help at all would be greatly appreciated.

I tried a little experiment in Word 2004. It seems to do what you want.
First open out all the fields to show their source.
You will see something like { EQ \o(o,-) } wherever your vowel with the
macron is supposed to be.
See that space between the closing parenthesis and the closing brace?
That seems to be the culprit.
Select everything inside the braces and paste it into the search part
of the search and replace dialog.
Paste it into the replace dialog as well, then delete the trailing
space.
Then, hit replace all.

You could also search for the field and replace it with the proper
unicode character in Word 2004. (Latin small letter o with macron whose
code is 014D in character palette). Using Times CE is a less than
perfect idea unless you want to move back to Word 5 later.

I could not get searching for a specific field *and* its contents to
work, but I did not try too hard. That meant that I had to change every
field in the document to an o with macron, which is not that brilliant.
To search for a field, turn off wilcards in search, and put ^d in the
search field.

Elliott Roper

unread,
Jul 6, 2006, 7:03:26 PM7/6/06
to

> I am editing a Latin course that was created in Word 5. All the Latin
> characters (the vowels with the bar above it) were put in using a code:

> (o,Ż) so that the letter appears correctly.


>
> When opening the document in Word 98 or 2004 it inserts those
> characters as an equation:

> { EQ \o(o,Ż) } They still appear correctly, but now there is a space


> after each character, so now there are spaces in the middle of a word:
> (eo rum) instead of (eorum).
>
> I have found a work around in Word 5 by doing a lot of search and
> replacing the code with the proper Times CE character, but I have
> several hundred pages to do and this will take a long time. I don't
> know if Word 5 supports macros (I don't have the help files anymore, I
> don't even know how to increase the view from 100% to 200% or higher).
>
> Is there a way in Word 98/2004 to search for the equations and either
> 1) removing the extra space or 2) replacing the equation entirely with
> the Times CE character? And would I be able to use a macro for this?
> (I'm not skilled at scripting macros, I usually record them)
>
> Any help at all would be greatly appreciated.

I tried a little experiment in Word 2004. It seems to do what you want.

Elliott Roper

unread,
Jul 6, 2006, 7:06:43 PM7/6/06
to

> I am editing a Latin course that was created in Word 5. All the Latin
> characters (the vowels with the bar above it) were put in using a code:

> (o,Ż) so that the letter appears correctly.


>
> When opening the document in Word 98 or 2004 it inserts those
> characters as an equation:

> { EQ \o(o,Ż) } They still appear correctly, but now there is a space


> after each character, so now there are spaces in the middle of a word:
> (eo rum) instead of (eorum).
>
> I have found a work around in Word 5 by doing a lot of search and
> replacing the code with the proper Times CE character, but I have
> several hundred pages to do and this will take a long time. I don't
> know if Word 5 supports macros (I don't have the help files anymore, I
> don't even know how to increase the view from 100% to 200% or higher).
>
> Is there a way in Word 98/2004 to search for the equations and either
> 1) removing the extra space or 2) replacing the equation entirely with
> the Times CE character? And would I be able to use a macro for this?
> (I'm not skilled at scripting macros, I usually record them)
>
> Any help at all would be greatly appreciated.

I tried a little experiment in Word 2004. It seems to do what you want.

Elliott Roper

unread,
Jul 6, 2006, 7:24:20 PM7/6/06
to
In article <070720060006436547%nos...@yrl.co.uk>, Elliott Roper
<nos...@yrl.co.uk> wrote:

<the same thing three times>

Sorry. I swapped routers, which assigned a different address to my
internal mail server, and I forgot I had to change the server address
in my usenet client for mail copy to self, where I banged the post out
three times before the penny dropped in my booze addled brain. (Becks
rather than Bordeaux if I must have an excuse)

John McGhie [MVP - Word and Word Macintosh]

unread,
Jul 7, 2006, 6:28:25 AM7/7/06
to
Yeah, that Becks will get you every time. Stick to quality Australian
Chateux Cardboarde...


On 7/7/06 9:24 AM, in article 070720060024209987%nos...@yrl.co.uk, "Elliott
Roper" <nos...@yrl.co.uk> wrote:

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <jo...@mcghie.name>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410

fogh...@lycos.com

unread,
Jul 7, 2006, 11:45:47 AM7/7/06
to
OK, I messed with it all day and came up with a couple of fixes.
First, I did your "show fields" and did a search and replace of the end
of the equation "¯) " removing the extra space "¯)" and that worked!

But then I wanted to replace the equation with the proper unicode
character. The only way I could find to do this was to take the
original document, run the above macro, then select all and paste it
into a new doc as unformatted text. Then the equations come over as
plain text "i¯".

I then run another macro changing all the vowels, "i¯" to the proper
character, "ChrW(299)" or "i".

It means I have to redo some formatting that I lost when pasting as
plain text, but I think on shorter documents it's worth it.

Both fixes seem to convert to pdf and print ok. Hopefully I won't have
more problems a few years down the line.

Thanks for your help.

Elliott Roper

unread,
Jul 7, 2006, 12:12:36 PM7/7/06
to
In article <1152287147.3...@k73g2000cwa.googlegroups.com>,
<fogh...@lycos.com> wrote:

> OK, I messed with it all day and came up with a couple of fixes.
> First, I did your "show fields" and did a search and replace of the end

> of the equation "Ż) " removing the extra space "Ż)" and that worked!


>
> But then I wanted to replace the equation with the proper unicode
> character. The only way I could find to do this was to take the
> original document, run the above macro, then select all and paste it
> into a new doc as unformatted text. Then the equations come over as

> plain text "iŻ".
>
> I then run another macro changing all the vowels, "iŻ" to the proper


> character, "ChrW(299)" or "i".
>
> It means I have to redo some formatting that I lost when pasting as
> plain text, but I think on shorter documents it's worth it.
>
> Both fixes seem to convert to pdf and print ok. Hopefully I won't have
> more problems a few years down the line.
>
> Thanks for your help.

A pleasure. Thanks for posting back your results.
Plain text was a bit drastic, but if it works...

I'd be interested if anyone has a trick for searching for a particular
field with specified contents, then replacing the whole field. I'm
thinking of the first trick (search for field source string) followed
by a clever macro to select and then delete the surrounding field
before inserting the replacement text.

In Word v.X I did fractions as EQ fields. It might be fun to
automatically turn them into proper unicode fractions.

Then again, I could get a life instead.
;-)

John McGhie [MVP - Word and Word Macintosh]

unread,
Jul 8, 2006, 12:10:30 AM7/8/06
to
Hi Elliot:

The basic incantation for searching for a field is:

^d XE "The index text here"

It *sort of* works, depending on the field type (XE is an Index field). At
least, on the PC they do. I can't remember whether the quotes go in the
Find string or not: I think they do.

However, I usually do this stuff in VBA because I can be much more sure of
the result there. In VBA you iterate the "Fields" collection, looking for a
"Type". When you find each field of your specified Type, you can then
return the "Code" or the "Result".

These come back as ranges, from which you can retrieve the Text to find out
whether the content is the one you are looking for. If you return the Code,
you are looking at everything except the curly braces. If you return the
Result, you see only what the user would see when the field updates.

So using Code, you can change the field from one type to another. I have a
macro somewhere that does this to change Index tags into Hyperlinks (so you
can use a concordance file to stick hyperlinks in a reference manual...
Nasty, but it works...)

There's some examples in the VBA Help that work sort-of :-)

To pre-empt your next question: It is possible to Find/Replace the code in
fields using Find/Replace with field codes revealed. You have to set things
up very carefully, because the possibility of corrupting the document by
mangling field codes is quite high :-)

Cheers

On 8/7/06 2:12 AM, in article 070720061712369737%nos...@yrl.co.uk, "Elliott
Roper" <nos...@yrl.co.uk> wrote:

--

Elliott Roper

unread,
Jul 8, 2006, 8:22:16 AM7/8/06
to
In article <C0D56D56.3CC4E%jo...@mcghie.name>, John McGhie [MVP - Word

and Word Macintosh] <jo...@mcghie.name> wrote:

> Hi Elliot:
>
> The basic incantation for searching for a field is:
>
> ^d XE "The index text here"
>
> It *sort of* works, depending on the field type (XE is an Index field). At
> least, on the PC they do. I can't remember whether the quotes go in the
> Find string or not: I think they do.

Ha! Thanks. That was easier than I feared it would be. It worked
without the quotes in the things I tried, which were EQs and TIMEs. It
wanted the contents of the field as written. e.g it wanted quotes round
a number picture as they are in the field.
It does not want to find fields at all unless their codes are revealed
prior to searching.

> However, I usually do this stuff in VBA because I can be much more sure of
> the result there. In VBA you iterate the "Fields" collection, looking for a
> "Type". When you find each field of your specified Type, you can then
> return the "Code" or the "Result".
>
> These come back as ranges, from which you can retrieve the Text to find out
> whether the content is the one you are looking for. If you return the Code,
> you are looking at everything except the curly braces. If you return the
> Result, you see only what the user would see when the field updates.
>
> So using Code, you can change the field from one type to another. I have a
> macro somewhere that does this to change Index tags into Hyperlinks (so you
> can use a concordance file to stick hyperlinks in a reference manual...
> Nasty, but it works...)

Ooh! That is *evil!!*

> There's some examples in the VBA Help that work sort-of :-)
>
> To pre-empt your next question: It is possible to Find/Replace the code in
> fields using Find/Replace with field codes revealed. You have to set things
> up very carefully, because the possibility of corrupting the document by
> mangling field codes is quite high :-)

Yep, that was implied in my original suggestion to fogharty. Your
additional hint is sufficient to do what I was looking for -- replacing
an entire field only when its contents match. Now I can replace all my
horrid 1/2 EQs with Unicode fractions whenever I work on a doc I did in
v.X

0 new messages