vba - How to get InsertCrossReference() to create a relative link instead of an absolute link? -


in word vba, have built tool uses word insertcrossreference() function automatically insert link word document, e.g., ‎the function can create link section 2.1.5.

the link worked , seemed fine. when "used under industrial conditions", found when writer changed document structure by, example, adding section, example, section 2.1.5 becomes section 2.1.6, f9 refresh function did not change link 2.1.6. stayed 2.1.5.

so after investigating problem, found problem insertcrossreference() function created absolute link instead of relative link.

on examining internals of link -- doing shift+f9 -- saw link looked follows:

{ ref _ref378698314 \n \h }

which apparently absolute link.

so tried changing \n \r change field

{ ref _ref378698314 \r \h }

that worked! when applied shift+f9 field, value of field became 2.1.6, supposed be.

so... questions:

  1. why absolute link (\n) created default?

  2. given absolute link created default, there way of changing default?

  3. even if there no way of changing default, best way of changing link type relative (\r).


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -