Re: Find and replace equations (Latin characters)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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%nospam@xxxxxxxxx, "Elliott
Roper" <nospam@xxxxxxxxx> wrote:

In article <1152287147.387062.188600@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<fogharty@xxxxxxxxx> 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.
;-)

--

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

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

.



Relevant Pages

  • Re: Multiple sheet search
    ... I saved th macro and closed/reopened the workbook. ... Dim ans As String, rng As Range ... res = MsgBox("Continue Searching?", vbYesNo) ...
    (microsoft.public.excel.programming)
  • Re: Duplexing on a macro
    ... I tried searching for a similar question before i submitted mine, ... ' Macro recorded 26/06/2007 by jodywilliams ... .PrintFieldCodes = False ... .PrintDrawingObjects = True ...
    (microsoft.public.word.docmanagement)
  • Re: Delete records from result-cell after a find-function call
    ... my macro is understandable in concept... ... Dim myResultRange As Range ... This is to force Excel to start searching in Column B from row 1 and ... The function looks for the first instance of "2" in column B, ...
    (microsoft.public.excel.programming)
  • Re: Excel and macro in VB
    ... The preference is generally to give somebody a helping hand in accomplishing ... so it is possible you don't actually need a macro to do ... Select all your data, from cell A1 to cell G620 or whatever your last cell is, ... > I stumbled in your forum searching for macro for excel. ...
    (microsoft.public.excel.misc)
  • Excel and macro in VB
    ... I stumbled in your forum searching for macro for excel. ... for searching for a value Search would be both numerical and character ...
    (microsoft.public.excel.misc)