Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mergeformat switch in Word index entries

Status
Not open for further replies.

gergelyv

Technical User
Jun 19, 2008
2
HU
Hello,

I have a rather technical question for which I couldn't find a definite answer after hours of research. What I did find is that I'm not the first one with this problem. Look at the following index entry:

Help{XE "Help" \* MERGEFORMAT}

The question is, is this valid and supported at all? Can the \* MERGEFORMAT switch appear in index entries? I don't know how it was created. (Probably some add-on software did it, possibly something like Robohelp, not sure.) But I suffer from problems with index entries like the one above: if I try to translate them using CAT tools like MemoQ or Trados, they become corrupted:

Help{xe "Help MERGEFORMAT }

My theory is that the whole \* MERGEFORMAT switch is invalid/unsupported in index entries in Word. Reading the help gives me an impression that it doesn't make sense to include them in index entries. Can someone confirm? Thank you.

Bests,
Gergely
 
My question is: is the following index entry correct/valid/supported in Word or not:
Help{XE "Help" \* MERGEFORMAT}

What I mean by unsupported and why I beleive it might be incorrect/invalid/unsupported. There is no way to create such an index entry from the Word UI, other than manually editing the index entry (the part inside the curly brackets). By just clicking around in Word, you can't create an index entry that has a \* MERGEFORMAT switch.

Such a switch doesn't even make much sense in an index entry IMO, since the \* (format) switch specifies how to display field results, and index entries produce no field results as far as I know. See:

Why I'm asking. I'm testing a piece of software that interoperates with Word. (Uses Word programatically to manipulate documents.) I assume that (since the Word UI does not allow index entries like the one above) the above index entry was created by another unknown piece of software that interoperates with Word. Or possibly manually by a user. I don't know, I only know that the above index entry causes problems in the application I'm testing, and also other similar applications. (These are translation tools that that aid the user in creating translated versions of their documents.) My assupmtion is that the error itself is not in the application I'm testing but in the above index entry, which (another assumption) is invalid in my opinion. But I'm not 100% sure.

I hope that makes my question complete. You see, it's not a very simple situation that you can easily describe in five words. :)

Bests,
Gergely
 
1. "(since the Word UI does not allow index entries like the one above)" - i.e. Help{XE "Help" \* MERGEFORMAT}

Apparently this is correct. When I set an XE reference they come out as:

Help { XE "Help" } - no MERGEFORMAT

You can manually add \* MERGEFORMAT to the field code, and it appears to make no difference when you generate the Index itself. I added it to my:

Help { XE "Help" }

so it became:

Help { XE "Help" \* MERGEFORMAT}

and updated the Index itself. The entry remain correct.

I even wrote an entry completely manually - Ctrl-F9 to make the curly brackets - and typed the code text, including the \* MERGEFORMAT. It works.

Now, if it IS causing a problem for you, and I am still unclear as to exactly what that problem is, you could remove the \* MERGEFORMAT.
Code:
Dim aField As Field
Dim r As Range
For Each aField In ActiveDocument.Fields
   If InStr(1, aField.Code, "\* MERGEFORMAT") > 0 Then
      Set r = aField.Code
      r.Text = Replace(r.Text, "\* MERGEFORMAT", "")
      aField.Update
   End If
Next
will go through the fields, removing \* MERGEFORMAT, and updating.

It works. I just tested with my manually entered:

For more { XE "more" \* MERGEFORMAT } information { XE "information" } see

One WITH \* MERGEFORMAT, one without.

The code above removed the \* MERGEFORMAT, with the result of:

For more { XE "more" } information { XE "information" } see

Note 1: Field.Code is a Range - NOT a string. So you must write to it as range.text.

Note 2: if you have other fields you will, of course, have to test for the XE first. Something like:
Code:
   If InStr(1, aField.Code, "XE") > 0 Then
     If InStr(1, aField.Code, "\* MERGEFORMAT") > 0 Then
       Set r = aField.Code
       r.Text = Replace(r.Text, "\* MERGEFORMAT", "")
       aField.Update
     End If
   End If
Of course if ALL of your XE fields have the MERGEFORMAT, then simply process them all.

Hope this helps.

faq219-2884

Gerry
My paintings and sculpture
 
Just a final note: "My theory is that the whole \* MERGEFORMAT switch is invalid/unsupported in index entries in Word."

You are correct (I think) that \* MERGEFORMAT is not added natively to index entry code. However, as far as I can see, it does not make any difference whatsoever to the actual generated Index.

So "unsupported", mmmmm, yes I suppose. "Invalid", well, no, I would not call it invalid.

Irrelevant?

I find it interesting that whatever it is that is writing these adds the \* MERGEFORMAT. I suspect that because most other fields DO have a \* MERGEFORMAT, an assumption was made.

And like a lot of assumptions, it can be wrong.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top