Modifying Hyperlink with openxml
<p>I'm trying to modify a hyperlink inside a word document.  The hyperlink is originally pointing to a bookmark in a external document.   What I want to do is change it to point to an internal bookmark that as the same Anchor.</p>

<p>Here's the code I use... It seem to work when I what the variables but when I look at the saved document it is exactly like the original.  </p>

<p>What is the reason my chances don't persist?</p>

<pre><code>// read file specified in stream 
MemoryStream stream = new MemoryStream(File.ReadAllBytes("C:\\TEMPO\\smartbook\\text1.docx"));
WordprocessingDocument doc = WordprocessingDocument.Open(stream, true);

MainDocumentPart mainPart = doc.MainDocumentPart;

// The first hyperlink -- it happens to be the one I want to modify 
Hyperlink hLink = mainPart.Document.Body.Descendants&lt;Hyperlink&gt;().FirstOrDefault();
if (hLink != null)
{
    // get hyperlink's relation Id (where path stores)
    string relationId = hLink.Id;
    if (relationId != string.Empty)
    {
        // get current relation
        HyperlinkRelationship hr = mainPart.HyperlinkRelationships.Where(a =&gt; a.Id == relationId).FirstOrDefault();
        if (hr != null)
        {
            // remove current relation
            mainPart.DeleteReferenceRelationship(hr);
            // add new relation with relation 
            // mainPart.AddHyperlinkRelationship(new Uri("C:\\TEMPO\\smartbook\\test.docx"), false, relationId);
        }
    }

    // change hyperlink attributes
    hLink.DocLocation = "#";
    hLink.Id = "";
    hLink.Anchor = "TEST";
}
// save stream to a new file
File.WriteAllBytes("C:\\TEMPO\\smartbook\\test.docx", stream.ToArray());
doc.Close();
</code></pre>