How can I change the hyperlink format

Hi,

I want to remove the underline from hyperlinks in footnotes. How can I do that? This is my code, but I don’t know how to proceed:

NodeCollection notes = document.GetChildNodes(NodeType.Footnote, true);

foreach (Aspose.Words.Notes.Footnote fn in notes)
{
    foreach (Aspose.Words.Fields.Field field in fn.Range.Fields)
    {
        if(field.Type == Aspose.Words.Fields.FieldType.FieldHyperlink)
        {
            field.Unlink();
        }
    }
}

Thanks in advance
@Nachti

@Nachti The provided code unlinks the hyperlink fields in footnotes, i.e. replaces hyperlink with simple text. See the attached input and result document:
in.docx (16.1 KB)
out.docx (11.9 KB)

If your goal is to change formatting of the hyperlink, you can simply change formatting of the Hyperlink style:

Document doc = new Document(@"C:\Temp\in.docx");
doc.Styles[StyleIdentifier.Hyperlink].Font.Underline = Underline.None;
doc.Save(@"C:\Temp\out_style.docx");

out_style.docx (12.2 KB)

@alexey.noskov

I want to remove it ONLY in the footnotes, not in general.

@Nachti In this case the code you have provided in your initial post does exactly this - it replaces hyperlinks with simple text in footnotes.

@alexey.noskov

Is there another way. In Word I can mark the hyperlink and disable the ‘underline’.

@Nachti You can achieve this using the following code:

Document doc = new Document(@"C:\Temp\in.docx");

NodeCollection notes = doc.GetChildNodes(NodeType.Footnote, true);
foreach (Aspose.Words.Notes.Footnote fn in notes)
{
    foreach (Run r in fn.GetChildNodes(NodeType.Run, true))
    {
        if (r.Font.StyleIdentifier == StyleIdentifier.Hyperlink)
            r.Font.Underline = Underline.None;
    }
}

doc.Save(@"C:\Temp\out.docx");