wiwidom was telling us:
wiwidom nous racontait que :
> Hallo,
>
[quoted text clipped - 18 lines]
> same code lines as above). When I'm executing the macro nothing is
> inserted.
This is because, as you found out, there is often a difference (bug?) in the
way Word works when we use its dialogs and when we try to do the same with
VBA.
In this case, when you insert your caption without a label, and then
manually (with the dialog from Insert > Reference > Cross...) Word manages
to create the appropriate hidden bookmark so that the cross reference works
and displays only the number (since the label is missing). When you do the
same by code, the cross-reference is inserted, but contains nothing as the
hidden bookmark that the .InserCrossReference method created is a single
insertion point just before the number in the caption (instead on
encompassing the number as it does when you use the dialog).
I am afraid I do not have a solution. I thought that you could invoke the
Insert Cross-reference dialog with VBA, but that also presents a whole new
sets of problems. (See
http://support.microsoft.com/default.aspx?scid=kb;en-us;q209668).
Another crazy idea would be to check the bookmark collection before
inserting the cross-reference, then again after. The new bookmark will be
the one the method just added in order to reference the caption. Then,
extend that bookmark to the right so as to include the number that follows.
Finally, update the cross-reference field so that it will display the
number.
But what if you add a second cross-reference to that same caption later on,
elsewhere in the document?
Why don't you want the label displayed?
If it is absolutely necessary to remove the labels, you could insert them
anyway, so that the cross reference code will work, but later, when the
document is finished, remove all the labels from the document using a
Find/Replace.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
wiwidom - 08 Aug 2006 22:43 GMT
I'd need to programm a semi-automatic bibliography. My idea was to use
the caption as the actual bibliography like: "1 Title, author" and the
references in the text with just "(1)", that's why I don't want the
labels. If you have any other idea doing that just let me know :)
I could of course insert bookmarks myself, but it would be much easier
and less error prone if WORD would do that internally. I like the idea
of comparing the bookmark list. i will try that when I'm back from
vacation next week.
thanks
Dom